Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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]
like image 771
Shiva Kumar N Avatar asked Dec 19 '22 00:12

Shiva Kumar N


2 Answers

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.

like image 154
Ullas Sharma Avatar answered Jan 09 '23 20:01

Ullas Sharma


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
like image 39
Shiva Kumar N Avatar answered Jan 09 '23 18:01

Shiva Kumar N