1

I have a problem with ServerFileUpload.parseRequest returning an empty list once in a while.

I have read this :

File upload with ServletFileUpload's parseRequest?

and this :

ServletFileUpload#parseRequest(request) returns an empty list

As stated above this only happens once in a while and usually if the person uploading retries after a while it works. I haven't been able to reproduce this behavior in my dev environment but it happens in production and it's driving me nuts.

Any directions on what might be causing this would be much appreciated.

Thx

Community
  • 1
  • 1
Sandy
  • 547
  • 3
  • 9
  • 20

2 Answers2

3

You can disable the Spring boot multipart support by setting spring.http.multipart.enabled=false in the application.properties. This helped me resolve the issue

MohamedSanaulla
  • 6,112
  • 5
  • 28
  • 45
0

If you are using a framework, it might be reading the request while attempting to resolve the data before it gets to your controller. The stream can only be read once. For instance, the default multipart resolver in my project using the SpringFramework was blocking me from successfully implementing a separate unique custom uploader for one particular requirement.

John C
  • 500
  • 3
  • 8
  • I'm having exactly this issue. I just added org.springframework.boot to an existing project and my file upload servlet started having this problem. Take it away and it works again. But I want to use it. Anyone know how to direct spring to ignore this particular servlet? I'm adding it through my pom.xml and using @RestController to define my servlet that I want to be controlled. Not sure why it is controlling anything else. Ugh. – crowmagnumb Apr 01 '15 at 23:33
  • It looks like Boot uses the standard `StandardServletMultipartResolver`. Check out MultipartAutoConfiguration.java to see what it's doing. The way I managed to get around the standard multipart handling (not using Boot) was to override `isMultipart` in `CommonsMultipartResolver` in your case `StandardServletMultipartResolver` to return false for the URIs I wanted to handle differently. Perhaps you can do the same. Better yet, if you never use the standard multipart handling, find how to override the `MultipartAutoConfiguration` to not set up a special MultipartResolver. – John C Apr 06 '15 at 15:12