This is a very specific question. Hopefully here someone here is very familiar with the FileUpload API.
If you are working with this API, you should be aware that when the maximum file size is exceeded, the following items cannot be read because FileSizeLimitExceededException is thrown, and if you try to call the hasNext()
method hasNext()
to iterate to the next element, an IOException is thrown. because the input stream is closed and you are trying to read it again.
This scenario is very bad because the following parameters cannot be read. Add this form:
<form action="..." method="post" enctype="multipart/form-data"> <input type="hidden" name="param1" value="foo"/> <input type="file" name="myFile"/><br/> <input type="hidden" name="param2" value="bar"/> <input type="submit"/> </form>
Now the file exceeds the maximum size. Result:
reads "param1".
"myFile" throws a FileSizeLimitExceededException.
"param2" is not readable.
I am trying to rewrite part of the API - with no luck - because I want to read the following elements (in this case "param2").
Has anyone had the same problem? How did you fix it?
Thanks.
EDIT: Well, I implemented the solution offered by BalusC. For the future:
Fileupload wrapper
Using FileUpload Wrap
If you think this shell needs something else, just say it. I do not accept this as a real solution, because changing and fixing the API itself is ideal.
source share