richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

preserveExtension has no use in the library? #309

Closed victorsferreira closed 2 years ago

victorsferreira commented 2 years ago

I realized that my uploads aren't working with version 1.3.1. I tried to check the internals, and am I wrong or preserveExtension is doing nothing right now?

Anytime I turn useTempFiles to true it creates files with the name like tmp-1-1648177925863 and never preserve the file extension.

This is my code right now

this.app.use(fileUpload({
            debug: true,
            useTempFiles: true,
            safeFileNames: false,
            preserveExtension: true,
            tempFileDir: path.join(__dirname, '../' , 'uploads')
        }));

The expected behavior is a file with name user.jpg is uploaded to a folder ./uploads and the final file looks like ./uploads/tmp-1-1648177925863.jpg

samiy803 commented 2 years ago

Preserves filename extension when using safeFileNames option.

So it looks like preserveExtension only matters when safeFileNames is set true. Otherwise, the file name remains unchanged.

richardgirges commented 2 years ago

Yes this only works in conjunction with safeFileNames