springboot 大文件上传问题

1. nginx(413 Request Entity Too Large)

     首先:【http|server|location】  下设置:client_max_body_size 100m

     重启nginx:systemctl restart nginx 

    

2. springboot设置   (报错类型:the request was rejected because its size (226000000) exceeds the configured maximum (104857600))

     配置文件添加:

 spring:
servlet:
multipart:
max-request-size: 300MB
max-file-size: 300MB

     启动类添加:

 @Value("${spring.servlet.multipart.max-request-size}")
private String maxFileSize;
@Value("${spring.servlet.multipart.max-file-size}")
private String maxRequestSize;
 @Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
// 单个数据大小
factory.setMaxFileSize(maxFileSize);
// 总上传数据大小
factory.setMaxRequestSize(maxRequestSize);
return factory.createMultipartConfig();
}

 

猜你喜欢

转载自www.cnblogs.com/changeEveryDay/p/12483806.html