I am trying to set maxFileSize but it is not honored

for spring-boot 2.x, file: src/main/resources/application.yaml

spring:
  servlet:
    multipart:
      max-file-size: -1
      max-request-size: -1

In addition to configuring max file size, you may also need to configure max request size if you have a single file that's greater than 10MB or you want to upload multiple files in the same request with sizes that total more than 10MB.

The exact properties that need to be used depend on the version of Spring Boot that you are using as they changed in 1.4:

Spring Boot 1.3.x and earlier

  • multipart.maxFileSize
  • multipart.maxRequestSize

Spring Boot 1.4.x and 1.5.x

  • spring.http.multipart.maxFileSize
  • spring.http.multipart.maxRequestSize

Spring Boot 2.x

  • spring.servlet.multipart.maxFileSize
  • spring.servlet.multipart.maxRequestSize