Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi file upload broken by unique request param name=file(n) after upgrade from 4.2.1 to 5.0.2 - #122

Open
jbowe opened this issue Aug 30, 2022 · 0 comments

Comments

@jbowe
Copy link

jbowe commented Aug 30, 2022

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant