SpringBoot1.x upgrade SpringBoot2.x stepped pit of file upload size limit
Foreword
LZ recently upgraded to 2.1.6 SpringBoo framework, stepped on some pit, presented here is file upload size limit.
Upgrade ago
#文件上传配置 1.5.9
spring:
http:
multipart:
enabled: true
max-file-size: 100Mb
max-request-size:100Mb
After the upgrade
##文件上传配置 2.x
spring:
servlet:
multipart:
enabled: true
max-file-size: 100Mb
max-request-size: 100Mb
the reason
We can see from the source code analysis to find SpringBoot relevant source - MultipartProperties
class
package org.springframework.boot.autoconfigure.web.servlet;
import javax.servlet.MultipartConfigElement;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.util.StringUtils;
@ConfigurationProperties(
prefix = "spring.servlet.multipart",
ignoreUnknownFields = false
)
public class MultipartProperties {
private boolean enabled = true;
private String location;
private String maxFileSize = "1MB";
private String maxRequestSize = "10MB";
private String fileSizeThreshold = "0";
private boolean resolveLazily = false;
.........
}
The above is SpringBoot2.x source, seen from above maxFileSize
, i.e., the maximum file size, default is limited to 1MB, maxRequestSize
i.e. the maximum request size, default is limited to 10MB. Notes that class prefix
= spring.servlet.multipart.