Shiva Kumar N
Shiva Kumar N

Reputation: 381

Unable to upload files larger than 1 MB

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]

Upvotes: 4

Views: 6645

Answers (3)

Ullas Sharma
Ullas Sharma

Reputation: 450

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.

Upvotes: 6

Shiva Kumar N
Shiva Kumar N

Reputation: 381

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

Upvotes: 4

Rahul Mahadik
Rahul Mahadik

Reputation: 12271

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

Upvotes: 2

Related Questions