[
https://issues.apache.org/jira/browse/WICKET-3525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13048315#comment-13048315
]
Phil Franken commented on WICKET-3525:
--------------------------------------
I have a work-around that at least gracefully closes the UploadProgressBar.
Although Tomcat still processes the entire file. I override FileUploadField
and return null if the file size is too big. On my file upload form I then
check for null and call error() (this means no file was selected or the file
was too big so the error message must be according).
Please note the forms max size must be greather than the max size set in the
CustomFileUploadField.
public class CustomFileUploadField extends FileUploadField {
public CustomFileUploadField(String id) {
super(id);
}
public CustomFileUploadField(String id, IModel<FileUpload> model) {
super(id, model);
}
@Override
public FileUpload getFileUpload() {
// Get request
final Request request = getRequest();
final FileItem item =
((IMultipartWebRequest)request).getFile(getInputName());
// If we successfully installed a multipart request
if (item != null && request instanceof IMultipartWebRequest) {
if (item.getSize() > Constants.MAXSIZE) {
return null;
}
if (item.getSize() > 0) {
return new FileUpload(item);
}
}
return null;
}
}
> Fileupload: full request body is read even when it is known that it is larger
> than the max allowed size
> -------------------------------------------------------------------------------------------------------
>
> Key: WICKET-3525
> URL: https://issues.apache.org/jira/browse/WICKET-3525
> Project: Wicket
> Issue Type: Improvement
> Components: wicket-core
> Affects Versions: 1.5-RC2
> Reporter: Attila Király
> Attachments: WICKET-3525-AJAX-handler.patch, WICKET-3525.patch
>
>
> Steps to reproduce (works with all major browers, I suggest using Chrome for
> this because it shows the upload progress status with a percentage in the
> lower left/right corner):
> 1. Go to http://www.wicket-library.com/wicket-examples/upload/single
> 2. Choose a file significantly larger than 100KB (app's max allowed size) for
> the first form. Post the first form.
> 3. The post will take long because the file is uploaded and processed by the
> server.
> The browsers send the content-length header and wicket compares this with the
> max allowed upload size in
> o.a.w.util.upload.FileUploadBase.FileItemIteratorImpl.FileItemIteratorImpl(FileUploadBase,
> RequestContext). It detects that it is larger than allowed and throws an
> exception which brakes the input parsing started by the Form component.
> However the input is still processed by something else.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira