Issue with sending 2 dimensional array of files
If you want to send multiple file attachments per OS you can use a List
instead of a 2-dimensional array in the spring controller.
@PostMapping(value = "/marches")
public Integer saveMarches(
@RequestPart("formJson") FooBean formJson,
@RequestPart("attachOs") List<MultipartFile> files
) throws IOException {
// Associate files with their os using the index in their name.
}
and in your angular code append the os index in the name of the file.
for (const [i, os] of formJson.os.entries()) {
if (os.attachment) {
for (const [j, file] of [...os.attachment].entries()) {
formData.append(`attachOs`, file, file.name + ":" + i );
}
}
}