httpservletsuploadrequestapache-commons-fileupload

Apache commons fileupload timeout only with Firefox


I use the Apache commons fileupload 1.4 library in my java project. I have a html part with a classic form with a file input and some hidden fields.

I have a problem with uploading files of around >500ko only with Firefox >= 52

It works well with files of 10mo in Chrome or Internet Explorer. But with Firefox, I have a timeout after waiting several minutes after submitting the form.

After some debugging, I see that the code responsible of the timeout is :

List<FileItem> items = (new ServletFileUpload(new DiskFileItemFactory())).parseRequest(request);

The part with cause wait is "parseRequest".

I try to debug the content of request with debugger in IntelliJ, but there is no way to copy entire content value of this request object in raw format.

It's working in these cases : - Firefox : version <= 52 or file size < 500ko (around, it's not really precise) - Internet Explorer - Chrome

There is no file size limit, it seems that depends on the request size, because the parsing request part is taking too much time...

I get the HTTP request with a Firefox extension in two cases. One generating uploading a file of 3mo which doesn't works (the request file is huge, 3x the size of the uploaded file) : https://code.empreintesduweb.com/13561.html

One generated uploading a file of 200ko which works (the request file is small) : https://code.empreintesduweb.com/13560.html

In fact, the main difference is that in Chrome or IE, I don't have the raw content of the uploaded file in the request headers :

The part with : obj stream .... endstream endobj

Only appear with Firefox...


Solution

  • Thanks for all your answer. Finally, I successfully resolve this issue, but in fact... not really. I notice that there was some specific things in my form. I had two inputs, one standard file input, and another which receive the file content encoded in base64 by some weird js before any upload. So I was having one time the raw content of the file, and also the file in base64. Why ?! I don’t know.

    But I delete all this, I create a new simple and clean form with a standard input file. I use the stream API from ServletFileUpload, and it works, and takes only few seconds for big files.

    So I don’t understand everything (why the problem was only on some browser for example), but I find a solution ;)

    Thank you !