Skip to content
Ameen Abozaid
Planned lessonJNR-023-L02

Limits and validation

  • Lesson 2 of 6
  • Junior
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-size and max-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 400 or 415 for wrong type, with a Problem Details body.
Draft outline details

Demonstration

yaml
spring.servlet.multipart.max-file-size: 5MB
spring.servlet.multipart.max-request-size: 6MB

Check 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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.