I'd like to create an endpoint which accepts any amount od different files from user.
For example:
Then, I'd like to receive it in my controller as a Map<String, FilePart> (or any other structure from which I'll know which file is which):
{
    "file1": "cactus-logo.png",
    "file2": "logo.png",
    "file3": "logo.png" (this one is actually different than file2 but has the same name)
}
I tried some combinations of @RequestPart...
- When I do: - @RequestPart Map<String, FilePart> files
or
    @RequestPart MultiValueMap<String, FilePart> files
I'm getting:
org.springframework.web.server.ServerWebInputException: 400 BAD_REQUEST "Required request part 'files' is not present"
- When I do: - @RequestPart("files") List<FilePart> files
I need to submit files like that:
And then I don't have the information which file is which (if they have the same name):
- Finally, I can do: - @RequestPart("file1") FilePart file1, @RequestPart("file2") FilePart file2, @RequestPart("file3") FilePart file3
And then it works as expected, but with that, it's possible to submit always only 3 files. I'd like to submit any number of files.
- As suggested in comments: - @PutMapping(value = "/{component}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public void upload( @RequestParam Map<String, MultipartFile> files ) throws IOException {
and the map is always empty:





 
    
 
    