Description
Feature description
Example controller on spring boot:
@PostMapping(value = "/testMultipart/{pathVar}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public void testMultipart(WrappedRq rq) {
log.info("fileName: {}", rq.fileName.getBytes());
}
public record WrappedRq(
@PathVariable
String pathVar,
@RequestParam
String queryVar,
// Part from multipart body
String fileName,
// Part from multipart body
MultipartFile file
) {}
Request debug:

As you see, attributes String fileName
and MultipartFile file
filled correctly.
Example on micronaut:
@Post(value = "/testMultipart/{pathVar}", consumes = MediaType.MULTIPART_FORM_DATA)
public void testMultipart(@RequestBean WrappedRq rq) {
log.info("fileName: {}", rq.fileName.getBytes());
}
@Introspected
public record WrappedRq(
@PathVariable
String pathVar,
@QueryValue
String queryVar,
// Part from multipart body
String fileName,
// Part from multipart body
CompletedFileUpload file
) {
}
Request debug:

I see two problems that would be good to fix:
-
At the moment, even if you specify the
@Part
annotations to the fileName and file attributes, Micronaut still won't understand what to put there. That is, at the moment it is impossible to use RequestBean and multipartfirmdata normally. -
Micronaut cannot correctly determine that the parameter of the endpoint method describes a
@RequestBean
unless you explicitly specify the annotation. Although this can be easily done if you analyze theWrappedRq
class and see that the value is Consumes.
In addition, Spring Boot understands constructions with a list of multipart files and puts all the parsed files there