Spring Boot修改最大上传文件限制:The field file exceeds its maximum permitted size of 1048576 bytes.
2017-04-18 17:23
921 查看
SpringBoot做文件上传时出现了The field file exceeds its maximum permitted size of 1048576 bytes.错误,显示文件的大小超出了允许的范围。查看了官方文档,原来Spring Boot工程嵌入的tomcat限制了请求的文件大小,这一点在Spring Boot的官方文档中有说明,原文如下
65.5 Handling Multipart File Uploads
Spring Boot embraces the Servlet 3 javax.servlet.http.Part API to support uploading files. By default Spring Boot configures Spring MVC with a maximum file of 1Mb per file and a maximum of 10Mb of file data in a single request. You may override these values,
as well as the location to which intermediate data is stored (e.g., to the /tmp directory) and the threshold past which data is flushed to disk by using the properties exposed in the MultipartProperties class. If you want to specify that files be unlimited,
for example, set the multipart.maxFileSize property to -1.The multipart support is helpful when you want to receive multipart encoded file data as a @RequestParam-annotated parameter of type MultipartFile in a Spring MVC controller handler method.
文档说明表示,每个文件的配置最大为1Mb,单次请求的文件的总数不能大于10Mb。要更改这个默认值需要在配置文件(如application.properties)中加入两个配置
需要设置以下两个参数
multipart.maxFileSize
multipart.maxRequestSize
Spring Boot 1.3.x或者之前
Spring Boot 1.4.x或者之后
很多人设置了multipart.maxFileSize但是不起作用,是因为1.4版本以上的配置改了,详见官方文档:spring boot 1.4
65.5 Handling Multipart File Uploads
Spring Boot embraces the Servlet 3 javax.servlet.http.Part API to support uploading files. By default Spring Boot configures Spring MVC with a maximum file of 1Mb per file and a maximum of 10Mb of file data in a single request. You may override these values,
as well as the location to which intermediate data is stored (e.g., to the /tmp directory) and the threshold past which data is flushed to disk by using the properties exposed in the MultipartProperties class. If you want to specify that files be unlimited,
for example, set the multipart.maxFileSize property to -1.The multipart support is helpful when you want to receive multipart encoded file data as a @RequestParam-annotated parameter of type MultipartFile in a Spring MVC controller handler method.
文档说明表示,每个文件的配置最大为1Mb,单次请求的文件的总数不能大于10Mb。要更改这个默认值需要在配置文件(如application.properties)中加入两个配置
需要设置以下两个参数
multipart.maxFileSize
multipart.maxRequestSize
Spring Boot 1.3.x或者之前
multipart.maxFileSize=100Mb multipart.maxRequestSize=1000Mb
Spring Boot 1.4.x或者之后
spring.http.multipart.maxFileSize=100Mb spring.http.multipart.maxRequestSize=1000Mb
很多人设置了multipart.maxFileSize但是不起作用,是因为1.4版本以上的配置改了,详见官方文档:spring boot 1.4
相关文章推荐
- [转]Spring Boot修改最大上传文件限制:The field file exceeds its maximum permitted size of 1048576 bytes.
- Spring Boot修改最大上传文件限制:The field file exceeds its maximum permitted size of 1048576 bytes.
- Spring Boot:The field file exceeds its maximum permitted size of 1048576 bytes.
- Spring Boot 批量上传: The field files exceeds its maximum permitted size of 1048576 bytes.
- Spring Boot 批量上传: The field files exceeds its maximum permitted size of 1048576 bytes.
- FileSizeLimitExceededException的maximum permitted size of 1048576 bytes问题
- .\ethercat.axf: error: L6047U: The size of this image (33488 bytes) exceeds the maximum allowed for
- 爬网日志中的警告信息:文件达到最大下载次数,The file reached the maximum download limit. Check that the full text of the document can be meani
- 关于github不给上传100m以上文件的错误:this exceeds GitHub's file size limit of 100.00 MB的解决方法
- 爬网日志中的警告信息:文件达到最大下载次数,The file reached the maximum download limit. Check that the full text of the document can be meani
- The size of this image (170286 bytes) exceeds the maximum allowed for this version of the linker
- 修改SharePoint上传文件大小限制(Changing Maximum Upload Size)
- struts上传图片过大限制:the request was rejected because its size (2407044) exceeds the configured m
- error: L6047U: The size of this image (32868 bytes) exceeds the maximum allowed for this version of
- the request was rejected because its size (***) exceeds the configured maximum (2097152) 上传不成功
- Dynamics CRM 修改Excel 最大导出记录限制及 最大上传文件限制
- 被人遗忘的MAX_FILE_SIZE文件上传限制大小参数
- 浅谈对struts2.2 the request was rejected because its size (XXXX) exceeds the configured maximum (XXXX)错
- File attachment or query results size exceeds allowable value of 1000000 bytes.
- Github 修正上传时“this exceeds GitHub’s file size limit of 100 MB”错误