question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FileInterceptors does not support different field names

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kamilmysliwieccommented, Jul 5, 2018

Added in the v5.1.0 release.

0reactions
lock[bot]commented, Sep 24, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found