الرفع متعدد الأجزاء (Multipart uploads)
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
accept a file in a request.
الموضوعات المخطط لها
- Browsers and clients upload files with
multipart/form-data: the body has several named parts, each with its own headers. - In Spring, bind a file part with
@RequestPartor@RequestParamof typeMultipartFile. MultipartFilegives the original name, content type, size, and a stream of bytes.- Other form fields can arrive in the same request.
- Test with
curl -F "file=@pen.png".
تفاصيل المخطط المبدئي
عرض عملي
@PostMapping(value = "/products/{id}/images", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
ResponseEntity<ImageResponse> upload(@PathVariable long id, @RequestParam("file") MultipartFile file) { ... }اختبر فهمك
Which content type carries file uploads?
أظهر الإجابة
multipart/form-data.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.