Closed mukundag closed 10 months ago
I tried using the example provided with package using postman with a file "option.ko". The size is correct and file contents are correct.
Node Version: v12.21.0
root@fxr90evk:/platform/www/web-app/node_modules/express-fileupload/example# node server.js Express server listening on port 8000 req.files >>> [Object: null prototype] { sampleFile: { name: 'tmp-1-1616613072957', data: <Buffer 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 01 00 b7 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 2c 05 00 00 00 00 00 00 00 ... 341662 more bytes>, size: 341712, encoding: undefined, tempFilePath: '', truncated: false, mimetype: undefined, md5: 'cdf49126018bb6e5f43f0e9e87ba7319', mv: [Function: mv] } }
Hi,
That can happens if client didn't send a file name or server was not able to get it some how. When the name empty or it is not a string, mw set it to random file name, see code below:
if (!fileName || typeof fileName !== 'string') return getTempFilename();
code: const fileUpload = require("express-fileupload"); app.use(fileUpload({ limits: { fileSize: 1024 1024 1024 // 1 GB }, abortOnLimit: true, safeFileNames: true, preserveExtension: 8, //debug: true, useTempFiles : true, tempFileDir : '/tmp/', uriDecodeFileNames : true, defParamCharset: 'utf-8' }));
app.post("/updateFile", (req, res) => { if (!req.files) { return res.status(400).send("No files were uploaded."); }
});
Log:
upload : {"name":"tmp-1-1616611601149","data":{"type":"Buffer","data":[]},"size":341712,"tempFilePath":"/tmp/tmp-2-1616611601150","truncated":false,"md5":"cdf49126018bb6e5f43f0e9e87ba7319"}