0

I got an exception like

2018-11-01 21:05:49.122 ERROR 31446 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1024 bytes.] with root cause org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1024 bytes.

why 413 http error wasn't raised automatically?

1 Answers1

2

You have to define maximum file size for a file upload.

Add below properties in application.properties

spring.http.multipart.max-file-size=128KB
spring.http.multipart.max-request-size=128KB

For spring boot 2.

spring.servlet.multipart.max-file-size=128MB
spring.servlet.multipart.max-request-size=128MB
spring.servlet.multipart.enabled=true

Refer this

Alien
  • 15,141
  • 6
  • 37
  • 57