How does SpringBoot limit file upload size through configuration files
This article mainly introduces how SpringBoot limits the upload size of files through configuration files. It is very detailed and has a certain reference value. Friends who are interested must finish reading it!
Through the configuration file (yml Properties) limit file upload size properties type profile settings # springboot 1.Xspring.http.multipart.max-file-size=50Mb spring.http.multipart.max-request-size=50Mb # springboot 2.Xspring.servlet.multipart.max-file-size=50Mb spring.servlet.multipart.max-request-size=50Mbyml type profile settings # # springboot 1.Xspring: http: multipart: enabled: true max-file-size: 50MB max-request-size: 50MB # # Springboot 2.x spring: servlet: multipart: enabled: true max-file-size: 50MB max-request-size: 50MB sets the file upload size limit-default is 1m
SpringBoot default upload file size cannot exceed 1MB
The following exception will be reported after it is exceeded:
Org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.
Solution method
Please add the following settings to the configuration file (application.properties/application.yml)
Lower version: 1.x
Spring.http.multipart.max-file-size=10MBspring.http.multipart.max-request-size=10MB
High version: 2.x
Spring.servlet.multipart.max-file-size=30Mbspring.servlet.multipart.max-request-size=30Mb
Or
Spring.servlet.multipart.maxFileSize=10MBspring.servlet.multipart.maxRequestSize=20MB above is all the contents of the article "how to limit the upload size of files by SpringBoot through configuration files". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!