عرض عملي: رفع صورة منتج وتنزيلها بالبث
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
build upload, list, and download for product images. Prepares JNR-023-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- 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.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.