FileInterceptors does not support different field names
See original GitHub issueI’m submitting a…
[ ] Bug report [X] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
there are two interceptors FileInterceptor
and FilesInterceptor
based on multer.uploadSingle
and multer.uploadArray
. they allow uploading a single file, or multiple files with same field name. however if say there is a form with two different filed name to be uploaded. like “avatar” and “passport”. currently there is not support for multer.fields
which addresses this requirement.
Expected behavior
based on current implementation, I suggest adding a new interceptor for this behaviour to “@nestjs/common” like:
import {FileFieldsInterceptor} from '@nest/common';
@UseInterceptors(FileFieldsInterceptor([{name: 'avatar', maxCount: 1}, {name: 'passport', maxCount: 1}]))
/...
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
unexpected filed error in nest js file upload - Stack Overflow
Hi I am not able to understand what is wrong with below method. it is throwing unexpected field error. even I have changed...
Read more >File upload | NestJS - A progressive Node.js framework
To upload all fields with arbitrary field name keys, use the AnyFilesInterceptor() decorator. This decorator can accept an optional options object as described ......
Read more >API with NestJS #55. Uploading files to the server
We use NestJS to store uploaded files on the server. We persist some information into the database, but it is just the metadata...
Read more >NestJS: Type-safe File Uploads - notiz.dev
This solves the problem that the fieldName for the FileInterceptor and the ApiBody are always the same and is convenient and easy to...
Read more >NestJS File Upload - Tech Seeker
The 'FileInterceptor' will be decorated on top of the file upload endpoint ... with our 'name' attribute value on the form file input...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Added in the v5.1.0 release.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.