本文介绍了Spring Rest API最大大小HTTP POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前有一个Java Spring Rest API,可以将图像base64上传到我的服务器。现在我想知道是否有一种方法可以限制上传大小,以便人们无法上传1GB并使我的服务器崩溃。
I currently have a Java Spring Rest API that enables images base64 to be uploaded to my server. Now I would like to know if there is a way I can limit the upload size so that people wont be able to upload 1GB and crash my server.
推荐答案
对于使用Spring Boot的用户,请考虑在 application.properties (或 application.yml )文件中设置以下参数:
For those using Spring Boot, consider setting the following parameters in your application.properties (or application.yml) file:
multipart.max-file-size=1Mb
multipart.max-request-size=10Mb
参见。
这篇关于Spring Rest API最大大小HTTP POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!