For example:

    Creating the body

    1. import io.micronaut.http.multipart.CompletedFileUpload
    2. import io.micronaut.http.multipart.StreamingFileUpload
    3. import io.micronaut.http.client.multipart.MultipartBody
    4. import org.reactivestreams.Publisher
    5. File file = new File(uploadDir, "data.txt")
    6. file.createNewFile()
    7. MultipartBody requestBody = MultipartBody.builder() (1)
    8. .addPart( (2)
    9. "data",
    10. MediaType.TEXT_PLAIN_TYPE,
    11. file
    12. ).build() (3)

    Creating a request

    1. HttpRequest.POST("/multipart/upload", requestBody) (1)
    2. .contentType(MediaType.MULTIPART_FORM_DATA_TYPE) (2)

    Creating a request

    1. HttpRequest.POST("/multipart/upload", requestBody) (1)
    1The multipart request body with different sets of data.
    2Set the content-type header of the request to multipart/form-data.