routing-controllers icon indicating copy to clipboard operation
routing-controllers copied to clipboard

Express.Multer.File[] usage triggering bug in action param validation logic

Open JamesMcFall opened this issue 5 years ago • 1 comments

Even the most basic example of uploading multiple files does not work. It results in an error: Invalid files, check 'error' property for more info.

This is because the validation logic for action parameters for routing-controllers is triggering when the parameter is an array.

There's some logic that says the param should be validated if it's not an object. Obviously Express.Multer.Files[] is an array and not an object so it's being incorrectly triggered (see screenshot below, line 262 along with values from debugger).

@Post()
public async post(@UploadedFiles(`files`) bundleFiles: Express.Multer.File[]): Promise<void>
{
    console.log(`BundleFiles`);
    console.log(bundleFiles);
}

Screen Shot 2020-06-25 at 3 02 31 PM

Hope this helps.

I'm using:

JamesMcFall avatar Jun 26 '20 01:06 JamesMcFall

@JamesMcFall Is this still relevant? Could you try the latest version?

attilaorosz avatar Dec 09 '22 16:12 attilaorosz