Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Spring maxFileSize and maxRequestSize not being honored?

Tags:

spring-boot

Intermediate Java skills, new to Spring, I'm going through one of Spring.io's Getting Started Guides: Uploading Files. Per the guide I'm setting some properties in an application.properties

multipart.maxFileSize: 128KB
multipart.maxRequestSize: 128KB
server.port = 8090

(I'm changing the tomcat port just to verify that this props file is being recognized, and the port is changed to 8090.) But running mvn spring-boot:run and accessing localhost:8090, I'm able to upload and subsequently requests/view a 700kb file. (Rather, I was expecting some application error to prevent both operations.) I've re-read the guide and googled around but can't figure out if I'm missing some other config to get these limits to be observed by the app. How do I get the app to observe these limits, or did I have an incorrect expectation from reading the guide?

like image 951
yamori Avatar asked Feb 10 '26 23:02

yamori


1 Answers

The problem that you've encountered happened because of the bug in the sample application. I see that they've upgraded the application to use Spring Boot 1.4 a week ago, but what they forgot to do is to migrate configuration.

Quote from Spring Boot 1.4 release note:

The multipart properties have moved from the multipart. namespace to the spring.http.multipart. namespace.

It means that obvious fix for you will be in modifying application.properties file.

Updated: I've filled issue for that: https://github.com/spring-guides/gs-uploading-files/issues/29

like image 181
Slava Semushin Avatar answered Feb 12 '26 16:02

Slava Semushin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!