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

4

8

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?

Homopolar answered 24/12, 2017 at 14:41 Comment(0)
G
15

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.

Glycolysis answered 24/12, 2017 at 15:50 Comment(1)
If the underlying webserver is Tomcat, you must also set this: server.tomcat.max-http-form-post-size=100MBDistich
D
1

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.

Dampier answered 30/5, 2019 at 10:34 Comment(0)
F
1
spring.servlet.multipart.max-file-size=1000MB
spring.servlet.multipart.max-request-size=1000MB


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

Above both the way not working in my version(1.3.4) also,

So that i used following way and it's working,

multipart.enabled=true
multipart.max-file-size=100MB
multipart.max-request-size=100MB
Featherstone answered 16/7, 2020 at 10:59 Comment(0)
D
1

For Spring boot version 2.4.3 and after this version use this

spring.servlet.multipart.max-file-size=-1 spring.servlet.multipart.max-request-size=-1

Doorjamb answered 21/2, 2021 at 0:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.