Skip to content
Ameen Abozaid
Planned lessonJNR-023-L01

Multipart uploads

  • Lesson 1 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

accept a file in a request.

Planned topics

  • 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 @RequestPart or @RequestParam of type MultipartFile.
  • MultipartFile gives 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".
Draft outline details

Demonstration

java
@PostMapping(value = "/products/{id}/images", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
ResponseEntity<ImageResponse> upload(@PathVariable long id, @RequestParam("file") MultipartFile file) { ... }

Check your understanding

Which content type carries file uploads?

Show answer

multipart/form-data.

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.