It appears Tomcat is not handling parallel uploads of the same multipart file by two different users.
Test
foo.pdf
more or less at the same timefoo.pdf
into the tmp folderResult
FileNotFoundException
as the tmp file was already deleted by the cleanup task of the faster request.Is there a way to avoid this - other than setting fileSizeThreshold
higher than maxFileSize
so it would never be written to disk in the first place.
Side note: this is a Spring Boot 2.1 application but this is irrelevant as it uses this Servlet 3.0 implementation by default.
I have an answer but it's not really satisfactory. We didn't figure out how to make this work with Tomcat's Servlet 3.0 implementation. However, once we switched to Apache commons-fileupload all was well.
So, for Spring (Boot) applications you would
spring.servlet.multipart.enabled: false
CommonsMultipartResolver
with a name of multipartResolver
commons-fileupload
dependency