Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot 2.0.0.M6 and file upload more than 10 MB

To my Spring Boot 2.0.0.M6 application.properties I have added the following lines:

spring.http.multipart.max-file-size=100MB 
spring.http.multipart.max-request-size=100MB

but when I try to upload to my RestController the 21MB file it fails with the following exception:

Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (21112803) exceeds the configured maximum (10485760)

I run my application on Embedded Tomcat packaged with Spring Boot.

How to properly configure my application in order to allow file upload up to 100MB?

like image 822
alexanoid Avatar asked Dec 24 '17 14:12

alexanoid


2 Answers

As shown in the documentation, and in its appendix, the correct properties are spring.servlet.multipart.max-file-size and spring.servlet.multipart.max-request-size.

like image 122
JB Nizet Avatar answered Sep 23 '22 04:09

JB Nizet


For SpringBoot 1.5.7 till or before 2.1.2 the property need to set in application.properties file are:

spring.http.multipart.max-file-size=100MB
spring.http.multipart.max-request-size=100MB

Also make sure you have application.properties file in "resources" folder. In case you are not sure with the size then "-1" is the value.

like image 30
Atul Avatar answered Sep 26 '22 04:09

Atul