I have the following spring-boot function that works and is able to read MultipartFiles that is sent from Angular front-end code.
@PostMapping(value = "/upload")
@Operation(summary = "Upload Files")
public ResponseEntity<Map<String, List<String>>> uploadFiles(@RequestParam("files") MultipartFile[] files) {
List<String> exceptions = new ArrayList<>();
List<String> fileNames = new ArrayList<>();
for (MultipartFile file : files) {
try {
Path fileStorage = get(DIRECTORY, fileName).toAbsolutePath().normalize();
copy(file.getInputStream(), fileStorage, true);
fileNames.add(fileName);
} catch (Exception e) {
exceptions.add(e.getClass().getName() + ": " + e.getMessage());
}
}
Map<String, List<String>> map = new HashMap<>();
map.put("data", fileNames);
map.put("errors", exceptions);
return ResponseEntity.ok().body(map);
}
My problem is, I have a couple of properties (checksum and author) that I need to get on each file. This is the sample of the file object that gets added as FormData.
How will I be able to get them in my backend code?