Limits and validation
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
reject files that are too big or the wrong kind.
Planned topics
- Set size limits in configuration (
spring.servlet.multipart.max-file-sizeandmax-request-size); verify property names for your version. - An oversized upload gives
413 Content Too Large(verify wording) or a mapped error; handle it with a clear message. - Check the declared content type against an allow-list (
image/png,image/jpeg), and reject empty files. - The declared type can lie; for stronger checks, inspect the first bytes (file signature) before accepting.
- Return
400or415for wrong type, with a Problem Details body.
Draft outline details
Demonstration
spring.servlet.multipart.max-file-size: 5MB
spring.servlet.multipart.max-request-size: 6MBCheck your understanding
Why check size in configuration?
Show answer
So huge uploads are stopped early.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.