Nest: FileInterceptors does not support different field names

Created on 29 May 2018  路  5Comments  路  Source: nestjs/nest

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}]))
/...
common done 馃憦 type type

Most helpful comment

Added in the v5.1.0 release.

All 5 comments

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

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

PR merged. Leaving opened to remember about the docs

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yanshuf0 picture yanshuf0  路  3Comments

mishelashala picture mishelashala  路  3Comments

cojack picture cojack  路  3Comments

anyx picture anyx  路  3Comments

rafal-rudnicki picture rafal-rudnicki  路  3Comments