[ 
https://issues.apache.org/jira/browse/TOMAHAWK-1381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12717133#action_12717133
 ] 

Leonardo Uribe commented on TOMAHAWK-1381:
------------------------------------------

Just one last note related to how t:inputFileUpload works when fails to load 
files:

Suppose a page with only one fileupload component. The ExtensionFilter / 
TomahawkFacesContextWrapper is configured in this way:

uploadMaxFileSize = 100k
uploadMaxSize = 300k
cacheFileSizeErrors = false (default)

And the user try to upload a file about 150k (let's call this one 
submittedFileSize). Commons-fileupload fails because uploadMaxFileSize <= 
submittedFileSize, but in this case it is not possible to continue the request 
restoring the view, because commons-fileupload does not recover from this 
error, so the request is deal as it was new one wrapping requestParameterMap to 
a empty one. The same happens if uploadMaxSize < submittedFileSize. It is 
possible to notify users about the exception inspecting the request attribute 
"org.apache.myfaces.custom.fileupload.exception", so the user can deal with it 
properly.

Now suppose the same scenario but set cacheFileSizeErros = true. If 
submittedFileSize == 150k, The file size exception happens but since 
submittedFileSize < uploadMaxSize, we can recover and continue request 
processing, because this error can be considered as a validation error, so a 
FacesMessage is attached later when validation occur. If submittedFileSize > 
uploadMaxSize, the request is considered invalid and the request is deal as a 
new one. 

Please note than if uploadMaxSize is not configured and uploadMaxFileSize is, 
then uploadMaxSize=uploadMaxFileSize.

> HtmlInputFileUpload does not fail gracefully when filesize exceeds 
> uploadMaxFileSize web.xml value
> --------------------------------------------------------------------------------------------------
>
>                 Key: TOMAHAWK-1381
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1381
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: File Upload
>    Affects Versions: 1.1.7, 1.1.8
>            Reporter: Phillip Webb
>            Assignee: Leonardo Uribe
>             Fix For: 1.1.9-SNAPSHOT
>
>         Attachments: file-upload.patch, file-upload2.patch, 
> testUsedForSolveTOMAHAWK1381.zip, TOMAHAWK-1381-fileupload6.patch
>
>
> When uploading a file using the HtmlInputFileUpload that exceeds that 
> uploadMaxFileSize web.xml setting the system fails without error and no form 
> data is not processed by JSF.
> I think that there are a number of reasons for this:
> - There is a bug in commons-fileupload that prevents failures from being 
> handled correctly (see FILEUPLOAD-169)
> - MultipartRequestWrapper calls FileUploads setSizeMax, this is the size for 
> the total upload, and not individual files, it should call setFileSizeMax
> - HtmlFileUploadRenderer calls fileUpload.parseRequest(request), this will 
> fail if any size exceptions are thrown, it would be better to use 
> fileUpload.getItemIterator and catch each exception.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to