4

I am trying to upload files larger than 1Mb with spring boot

hereorg.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.
    at org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl$FileItemStreamImpl.<init>(FileUploadBase.java:618) ~[tomcat-embed-core-8.5.28.jar:8.5.28]
Rahul Mahadik
  • 11,668
  • 6
  • 41
  • 54
Shiva Kumar N
  • 371
  • 3
  • 11
  • 3
    Possible duplicate of [Max Limit of MultipartFile in spring boot](https://stackoverflow.com/questions/34177873/max-limit-of-multipartfile-in-spring-boot) – Sangam Belose Mar 19 '18 at 05:51
  • may be but i am not able to upload still, i have done evrey thing what is there in that ticket. – Shiva Kumar N Mar 19 '18 at 06:25

3 Answers3

6

If you are using Spring 2.0 or higher add the below code which is working for me

application.properties

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

application.yml

spring:
  http:
    multipart:
      enabled: true
      max-file-size: 128MB
      max-request-size: 128MB

If you just want to control the multipart properties then multipart.max-file-size and multipart.max-request-size properties should work.

Ullas Sharma
  • 450
  • 11
  • 22
4

File uploading problem solved by this configuration in application.yml:

spring:
  data:
    mongodb:
      host: localhost
      port: 27017
      database: testone
  servlet:
    multipart:
      enabled: true
      maxFileSize: 500MB
      maxRequestSize: 500MB
      file-size-threshold: 500MB
Akshatha S R
  • 1,237
  • 1
  • 15
  • 30
Shiva Kumar N
  • 371
  • 3
  • 11
2

If you are using application.yml

spring:
  http:
    multipart:
      enabled: true
      max-file-size: 50MB
      max-request-size: 50MB

or

If you are using application.properties

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

Hope it will works

Rahul Mahadik
  • 11,668
  • 6
  • 41
  • 54