dmitriy-nz / nestjs-form-data

NestJS middleware for handling multipart/form-data, which is primarily used for uploading files.
https://www.npmjs.com/package/nestjs-form-data
MIT License
117 stars 23 forks source link

@HasMimeType and @MaxFileSize only work for @IsFile #11

Closed Thiti-Dev closed 3 years ago

Thiti-Dev commented 3 years ago

The decorators such as HasMimeType, MaxFileSize . . . only works for Single image file -> @IsFile

But when I tried with the @isFiles -> {Array of FileSystemStoreFile} with {each:true} -> no matter what the mime or size is it will be always valid without getting the validation error

image

dmitriy-nz commented 3 years ago

Hi, try not to use the @Type (() => Array) decorator on an array of files.

Thiti-Dev commented 3 years ago

@dmitriy-nz

Ahh It was my fault, I tested this with postman and I forget to set the form-data field to be an array And yeah type casting isn't needed

Now everything works fine

Thank you

dmitriy-nz commented 3 years ago

Glad I helped you! In any case, an error should have been thrown when checking @IsFiles(). I will check it 😉