private FileUploadListener fileUploadListener;
@Override
public MultipartHttpServletRequest resolveMultipart(HttpServletRequest request) throws MultipartException {
String encoding = determineEncoding(request);
FileUpload fileUpload = prepareFileUpload(encoding);
if (fileUploadListener != null) {
fileUpload.setProgressListener(fileUploadListener);
request.getSession(false).setAttribute("upload_listener", fileUploadListener);
}
try {
List fileItems = ((ServletFileUpload) fileUpload).parseRequest(request);
MultipartParsingResult parsingResult = parseFileItems(fileItems, encoding);
Map<String, String> multipartContentTypes = new HashMap<String, String>();
for (List<MultipartFile> files : parsingResult.getMultipartFiles().values()) {
for (MultipartFile f : files) {
multipartContentTypes.put(f.getName(), f.getContentType());
}
}
return new DefaultMultipartHttpServletRequest(request, parsingResult.getMultipartFiles(), parsingResult.getMultipartParameters(), multipartContentTypes);
}
catch (FileUploadBase.SizeLimitExceededException ex) {
throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
}
catch (FileUploadException ex) {
throw new MultipartException("Could not parse multipart servlet request", ex);
}
}