Java – Spring Rest API maximum size HTTP POST

javarestspring

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.

Best Solution

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

See Common application properties.