richardgirges / express-fileupload

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

MAX_EXTENSION_LENGTH causes legitimate "[filename].XLSX" files to be renamed to "[filename]X.LSX" #243

Closed odnarb closed 4 years ago

odnarb commented 4 years ago

Try uploading an .xlsx file with this config set.

Also, pretty sure "preserveExtensionLengh" is a typo. :)

https://github.com/richardgirges/express-fileupload/blob/c7a6b9c8ca6f88bc2cfe2ad2f0881f21f629c683/lib/utilities.js#L9

Maybe I haven't tried a bunch of different options, but I instantiate the file upload middleware with this:

  app.use(fileUpload({
      createParentPath: true,
      safeFileNames: true,
      preserveExtension: true,
      abortOnLimit: true,
      useTempFiles: true,
      tempFileDir: dir_uploads,

      //busboy options
      highWaterMark: 2 * 1024 * 1024, // Set 2MB buffer
      limits: {
        fileSize: 200 * 1024 * 1024 //set 200MB limit
      }

  }))
Code42Cate commented 4 years ago

Hey,

I think if you use preserveExtension: 4 it should work :)

Cheers, Jonas

odnarb commented 4 years ago

Thank you that worked. I was pretty tired that night, didn't see the parseInt() at ALL. hah!