I know that there are plenty of questions covering the topic, but I cannot figure out how to achieve the following requirement.
I would like to upload a list of files, each one containing some extra information. In the java world this would mean the following:
@NoArgsConstructor
@Getter
public class SkillsVerificationData {
String type; // this information is related to the file
MultipartFile file;
}
Question 1:
Is this possible for a RestController
to achieve such a mapping using a wrapper object? (See first answer of the referenced question- @ModelAttribute)
Question 2: Using the following controller method answered in the question referenced above
@RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = { "multipart/form-data" })
public void upload(@RequestPart("type") @Valid String type,
@RequestPart("file") @Valid @NotNull @NotBlank MultipartFile file) {
}
I assume that it applies for a single file. How should the request parts be defined/described to achieve uploading a List<SkillsVerificationData>
or SkillsVerificationData
[] ?
Note that the client sends the information using FormData
.
Thanks in advance!