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
129 stars 24 forks source link

Check file type based on buffer instead of extension #31

Closed 0x67 closed 2 years ago

0x67 commented 2 years ago

So right now the I guess it only check for file type based on its extension, do you plan to add support for it? This is quite an edge cases but simple to implement using file-type library.

dmitriy-nz commented 2 years ago

Hi, right now the file check is done via mime type which is given by busboy image good idea to check the file type via a magic number, we should add some validation decorators. thanks for idea

0x67 commented 2 years ago

Ah my own decorator use file-type to check the buffer, I can rewrite it to use busboy then I'll submit a PR

dmitriy-nz commented 2 years ago

I have already started the implementation, there will be a new version soon with built-in decorators to check file extensions via file-type. It will check the type via incoming stream from busboy, this will improve version backward compatibility. I also added some tests for this

0x67 commented 2 years ago

I'm looking forward to it 🙂

And thank you for the awesome library!

dmitriy-nz commented 2 years ago

Hi, version 1.8.0 has been released! Please check new version and change log and If the problem has been solved, then close it

0x67 commented 2 years ago

Hi @dmitriy-nz, I ran tests in my projects with the new version and it looks good Thank you!