I'm developing application based on Spring Boot and AngularJS using JHipster. My question is how to set max size of uploading files?
If I'm trying to upload to big file I'm getting this information in console:
DEBUG 11768 --- [io-8080-exec-10] c.a.app.aop.logging.LoggingAspect:
Enter: com.anuglarspring.app.web.rest.errors.ExceptionTranslator.processRuntimeException() with argument[s] =
[org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException:
org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.]
And server response with status 500.
How to set that?
For Spring Boot 2.+, make sure you are using
spring.servlet
instead ofspring.http
.If you have to use tomcat, you might end up creating EmbeddedServletContainerCustomizer, which is not really nice thing to do.
If you can live without tomat, you could replace tomcat with e.g. undertow and avoid this issue at all.
If you get a "connection resets" error, the problem could be in the Tomcat default connector maxSwallowSize attribute added from Tomcat 7.0.55 (ChangeLog)
From Apache Tomcat 8 Configuration Reference
For Springboot embedded Tomcat declare a TomcatEmbeddedServletContainerFactory
Java 8:
Java 7:
Or in the Tomcat/conf/server.xml for 5MB