Demo: product image upload and streaming download
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
- Add configuration for the storage directory and size limits.
- Implement
POST /products/{id}/images: check type and size, generate a UUID name, save to the storage directory, and return201withLocation. - Implement
GET /products/{id}/images(list) andGET /images/{imageId}(stream with the rightContent-Type). - 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. - Upload a 20 MB file and a fake
.pngand show both rejected.
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.