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

FileInterceptors does not support different field names #741

Closed
thg303 opened this issue May 29, 2018 · 5 comments
Closed

FileInterceptors does not support different field names #741

thg303 opened this issue May 29, 2018 · 5 comments

Comments

@thg303
Copy link
Contributor

thg303 commented May 29, 2018

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}]))
/...
@kamilmysliwiec
Copy link
Member

Hi @thg303,
Good idea! Are you interested in creating a PR? If not, I'll ship it soon anyway 👍

@thg303
Copy link
Contributor Author

thg303 commented May 30, 2018

here's my PR. please check it out. please let me know if there's anything missed/wrong about it.

@kamilmysliwiec
Copy link
Member

PR merged. Leaving opened to remember about the docs

@kamilmysliwiec
Copy link
Member

Added in the v5.1.0 release.

@lock
Copy link

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.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants