Springboot上传视频文件过大,报错:The field multiFile exceeds its maximum permitted size of 1048576 bytes.

原因为原来Spring Boot工程嵌入的tomcat限制了请求的文件大小,需要在application.yml文件中设置参数。

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

Springboot1.4及以上官方文档有所改动,详见:
Spring Boot 1.4.x

spring.http.multipart.maxFileSize=100Mb
spring.http.multipart.maxRequestSize=1000Mb

Spring Boot 2.0之后

spring.servlet.multipart.max-file-size=100MB

参考:

Spring Boot修改最大上传文件限制:The field file exceeds its maximum permitted size of 1048576 bytes._Chopper_Tony的博客-CSDN博客SpringBoot做文件上传时出现了The field file exceeds its maximum permitted size of 1048576 bytes.错误,显示文件的大小超出了允许的范围。查看了官方文档,原来Spring Boot工程嵌入的tomcat限制了请求的文件大小,这一点在Spring Boot的官方文档中有说明,原文如下65.5 Handling Multipa...https://blog.csdn.net/awmw74520/article/details/70230591?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165253726016780366560269%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=165253726016780366560269&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-1-70230591-null-null.142^v9^pc_search_result_cache,157^v4^control&utm_term=The+field+file+exceeds+its+maximum+permitted+size+of+1048576+bytes.&spm=1018.2226.3001.4187

你可能感兴趣的:(spring,boot,java,spring)