-
Notifications
You must be signed in to change notification settings - Fork 77
Description
I support an Angular/Java/Spring webapp.
Recently upgraded angular-file-uploader from 4.2.1 to 5.0.2 to take advantage of "replaceTexts:" feature.
With 4.2.1 all of the files POSTed with multiple file upload shared the same request parameter name i.e. "name=file";
After the upgrade to 5.0.2 each file received a unique request parameter name that appears to have an array index appended e.g.: "name=file0" ..."name=file1" .
This app. uses Spring MVC to access the multiple files uploaded as a "MultipartFile[]" array.
Example API method:
@PostMapping("/addAttachment/{workInfoId}")
public WorkInfoJson addAttachment(@PathVariable("workInfoId") int workInfoId,
@RequestParam("file") MultipartFile[] file {...}
Example request from devtools:
------WebKitFormBoundaryqVXaFB7sh19ZQdHm
Content-Disposition: form-data; name="file0"; filename="testFile1.xlsx"
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
------WebKitFormBoundaryqVXaFB7sh19ZQdHm
Content-Disposition: form-data; name="file1"; filename="testFile2.xlsx"
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Is there a way to control the request parameter name assigned to multiple files so that the Spring MVC method will "see" them as an array of files?
My apologies if this is something simple that I have overlooked.
Thanks!
Versions:
- Angular 13.3.11
- angular-file-uploader 5.0.2
- Spring 5.3.19
- Chrome 103.0.5060.134