简体   繁体   English

413 上传多部分文件时请求实体太大

[英]413 Request Entity Too Large while uploading a multipart file

I've the below uploadfile method to upload multipart files and I see 413 Request Entity Too Large while uploading a large size file like 28MB.我有下面的uploadfile方法来上传多部分文件,我在上传像28MB这样的大文件时看到413请求实体太大。 I've set maxPostSize to 50MB in tomcat 9 server configurations and also tried which is suggested in below link.我已经在 tomcat 9 服务器配置中将maxPostSize设置为 50MB,并且还尝试了以下链接中的建议。 I've added below spring.servlet properties in application.properties file.我在application.properties文件中添加了spring.servlet属性。

spring.servlet.multipart.max-file-size=-1
spring.servlet.multipart.max-request-size=-1
spring.servlet.multipart.enabled=true
@PostMapping(********)
@ResponseBody
public response uploadfile(
    @RequestParam(value = "id", required = true) String id,
    @RequestPart(value = "file", required = false) MultipartFile multipartFile,
    @RequestPart(required = true) data data) throws ServicesException {
    return service.uploadfile(id, multipartFile, data);
}

I've tried suggestions in below link but still seeing the same error: Spring Boot Upload Multipart 413 Request Entity Too Large我已经尝试了以下链接中的建议,但仍然看到相同的错误: Spring Boot Upload Multipart 413 Request Entity Too Large

Do you use ngrok or any proxy?您使用ngrok或任何代理吗? By default in Spring, you should get:默认情况下,在 Spring 中,您应该获得:

"status": 500,
"error": "Internal Server Error",
"message": "Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.",

So I think you should check some firewall configurations, because the issue may lie there.所以我认为你应该检查一些防火墙配置,因为问题可能出在那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM