private JSONObject getFileName(HttpServletRequest request) throws IOException {
byte[] bufRequest = getRequestPostBytes(request);
String charEncoding = request.getCharacterEncoding();
if (charEncoding == null) {
charEncoding = "UTF-8";
}
request.getInputStream();
String fileStr = new String(bufRequest, charEncoding);
JSONObject fileJson = JSONObject.parseObject(fileStr);
String file = fileJson.getString("file");
return fileJson;
}
private byte[] getRequestPostBytes(HttpServletRequest request)
throws IOException {
int contentLength = request.getContentLength();
if(contentLength<0){
return null;
}
byte buffer[] = new byte[contentLength];
for (int i = 0; i < contentLength;) {
int readlen = request.getInputStream().read(buffer, i,
contentLength - i);
if (readlen == -1) {
break;
}
i += readlen;
}
return buffer;
}