Skip to content
Ameen Abozaid
Planned lessonJNR-023-L06

Demo: product image upload and streaming download

  • Lesson 6 of 6
  • Junior
On This Lesson 3 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

build upload, list, and download for product images. Prepares JNR-023-LAB1.

Draft outline details

Step by step

  1. Add configuration for the storage directory and size limits.
  2. Implement POST /products/{id}/images: check type and size, generate a UUID name, save to the storage directory, and return 201 with Location.
  3. Implement GET /products/{id}/images (list) and GET /images/{imageId} (stream with the right Content-Type).
  4. Planned mistake: the first version saves the file using file.getOriginalFilename(); a name with ../ writes outside the folder. Fix: generate the name and keep the original only as metadata.
  5. Upload a 20 MB file and a fake .png and show both rejected.

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.

Type to search levels, phases, modules and lessons.