本文介绍了如何设置上传文件的最大大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用JHipster开发基于Spring Boot和AngularJS的应用程序。
我的问题是如何设置上传文件的大小?
如果我试图上传到大文件, m在控制台获取这些信息:
DEBUG 11768 --- [io-8080-exec-10] caapp.aop。 logging.LoggingAspect:
输入:com.anuglarspring.app.web.rest.errors.ExceptionTranslator.processRuntimeException()与参数[s] =
[org.springframework。 web.multipart.MultipartException:无法解析多部分的servlet请求;嵌套异常是java.lang.IllegalStateException:
org.apache.tomcat.util.http.fileupload.FileUploadBase $ FileSizeLimitExceededException:字段文件超出了允许的最大大小1048576字节。]
以及状态500的服务器响应
如何设置在Spring 1.4中,你可以在你的application.properties文件中添加以下几行来设置文件大小的限制:??????????????????????????
spring.http.multipart.max-file-size = 128KB
spring.http.multipart.max-request -size = 128KB
为我工作。来源:
I'm developing application based on Spring Boot and AngularJS using JHipster.My question is how to set max size of uploading files?
If I'm trying to upload to big file I'm getting this information in console:
DEBUG 11768 --- [io-8080-exec-10] c.a.app.aop.logging.LoggingAspect:
Enter: com.anuglarspring.app.web.rest.errors.ExceptionTranslator.processRuntimeException() with argument[s] =
[org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException:
org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.]
And server response with status 500.
How to set that?
解决方案
Also in Spring boot 1.4, you can add following lines to your application.properties to set the file size limit:
spring.http.multipart.max-file-size=128KB
spring.http.multipart.max-request-size=128KB
Worked for me. Source: https://spring.io/guides/gs/uploading-files/
这篇关于如何设置上传文件的最大大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!