I am using Spring Boot 1.1.3 with CommonsMultipartResolver to allow multiple files to download at the same time.
I get this stack when I try to upload a file larger than 1 MB:
Caused by: org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field files[] exceeds its maximum permitted size of 1048576 bytes. at org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl$FileItemStreamImpl$1.raiseError(FileUploadBase.java:637) at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.checkLimit(LimitedInputStream.java:76) at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:135) at java.io.FilterInputStream.read(FilterInputStream.java:107)
I tried to set the maximum download size as follows:
public MultipartResolver multipartResolver() { CommonsMultipartResolver resolver = new CommonsMultipartResolver(); resolver.setMaxUploadSize( 100 * MEGABYTE_IN_BYTES ); return resolver; }
However, this does not work. I found this Spring file upload guide and they use MultipartConfigFactory instead. However, now I need to use the MultipartFile class instead of the MultipartHttpServletRequest in my controller.
Using MultipartHttpServletRequest I could do getFileMap() to get all the files, but there is no such method on MultipartFile .
Any ideas on how to work with MultipartConfigFactory and multiple files? I use jquery-file-upload on the client, if that matters.
source share