Max Limit of MultipartFile in spring boot

2019-01-22 07:33发布

问题:

Is there a maximum file size that spring boot can handle in a MultipartFile upload process. I know that I can set the maxFileSize in the property like multipart.maxFileSize=1Mb.

So, like that can I allow a huge file to upload, like 50MB. The application runs on the tomcat server integrated with spring boot. Do I need to configure the tomcat server also. Or is the file size unlimited?

回答1:

For those using Spring Boot 2.0 (as of M1 release), the property names have changed to:

spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB

Note the prefix is "spring.servlet" instead of "spring.http".



回答2:

It seems setting -1 will make it for infinite file size.

multipart.maxFileSize=-1

multipart.maxRequestSize=-1



回答3:

Actually setting multipart.max-file-size=128MB multipart.max-request-size=128MB works for me without additional configurations.