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

Upload multiple files using @UploadedFiles() and @UploadedFile causes multer error #1618

Closed
2 of 4 tasks
Yoronex opened this issue Apr 29, 2024 · 2 comments
Closed
2 of 4 tasks

Comments

@Yoronex
Copy link
Contributor

Yoronex commented Apr 29, 2024

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

The docs about file uploads suggest that it is possible to use is possibly in the example.

  @Post("uploadFile")
  public async uploadFile(
      @FormField() title: string,
      @FormField() description: string,
      @UploadedFiles() files: Express.Multer.File[],
      @UploadedFile() file: Express.Multer.File,
  ): Promise<void> {
    console.log(files);
  }

Current Behavior

A multer error is thrown.

MulterError: Unexpected field
    at wrappedFileFilter (C:\Users\roy.kakkenberg\WebstormProjects\arvisan-backend\node_modules\multer\index.js:40:19)
    at Multipart.<anonymous> (C:\Users\roy.kakkenberg\WebstormProjects\arvisan-backend\node_modules\multer\lib\make-middleware.js:107:7)
    at Multipart.emit (node:events:514:28)
    at Multipart.emit (node:domain:488:12)
    at HeaderParser.cb (C:\Users\roy.kakkenberg\WebstormProjects\arvisan-backend\node_modules\busboy\lib\types\multipart.js:358:14)
    at HeaderParser.push (C:\Users\roy.kakkenberg\WebstormProjects\arvisan-backend\node_modules\busboy\lib\types\multipart.js:162:20)
    at SBMH.ssCb [as _cb] (C:\Users\roy.kakkenberg\WebstormProjects\arvisan-backend\node_modules\busboy\lib\types\multipart.js:394:37)
    at feed (C:\Users\roy.kakkenberg\WebstormProjects\arvisan-backend\node_modules\streamsearch\lib\sbmh.js:248:10)
    at SBMH.push (C:\Users\roy.kakkenberg\WebstormProjects\arvisan-backend\node_modules\streamsearch\lib\sbmh.js:104:16)
    at Multipart._write (C:\Users\roy.kakkenberg\WebstormProjects\arvisan-backend\node_modules\busboy\lib\types\multipart.js:567:19) {
  code: 'LIMIT_UNEXPECTED_FILE',
  field: 'files',
  storageErrors: []
}

Possible Solution

Steps to Reproduce

  1. Copy the example from the TSOA docs to upload files into a controller class.
  2. Try to upload two files (one for each name).
  3. Multer throws an error.

Context (Environment)

Version of the library:
Version of NodeJS:

  • Confirm you were using yarn not npm: [ ]

Detailed Description

For my project, I wish to create and endpoint that takes multiple files as input. These files need to be organized, so I wish to use a combination of @UploadedFile and @UploadedFiles parameters for my endpoint.

Breaking change?

Copy link

Hello there Yoronex 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

@Yoronex
Copy link
Contributor Author

Yoronex commented Apr 29, 2024

Accidentally pressed enter, was not finished with writing the bug report.

@Yoronex Yoronex closed this as completed Apr 29, 2024
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