Closed kamilmclearcode closed 7 months ago
Hi @kamilmclearcode , you are right, it is not exported.
I fixed it in the version nestjs-form-data@1.9.4
, it is already available. Please try it out.
Use HasExtension
decorator:
@HasMimeType(allowedMimeTypes: string[] | string, strictSource?: MetaSource | ValidationOptions, validationOptions?: ValidationOptions)
Hello @dmitriy-nz
Thanks for the fix, however there is something wrong with the export. This is what my IDE says:
And it makes me do the import this way: import { MetaSource } from 'nestjs-form-data/dist/interfaces';
- should it be like that?
BTW, just to clarify - tests I made in my app suggests that MetaSource.bufferMagicNumber
is the default setting, if you don't set it explicitely on the decorator. Is that correct?
@kamilmclearcode yeah, it's still my bad, fixed in nestjs-form-data@1.9.5
@dmitriy-nz thank you, all good now
I try to use HasMimeType like that:
@HasMimeType(['image/png'], 'bufferMagicNumber')
, but I'm getting an errorArgument of type '"bufferMagicNumber"' is not assignable to parameter of type 'MetaSource | ValidationOptions'
I'm trying to import
MetaSource
to use the enum value:import { MetaSource } from 'nestjs-form-data';
but it says:Module '"nestjs-form-data"' has no exported member 'MetaSource'
Am I doing something wrong, or
MetaSource
is not publicly available?Maybe, I don't need it in the first place? I wish the validation DOES check the
magic number
usingfile-type
lib, README saysThe default is simple mode, which does not check the data source, but you can pass a second argument to strictly check the mime-type and data source.
, but it doesn't show example usage, how to do it?