richardgirges / express-fileupload

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

Tmp folder can't be found on server but works well on localhost #333

Closed Trinity6264 closed 10 months ago

Trinity6264 commented 1 year ago

app.use( "/api/v1/product", fileUpload({ useTempFiles: true, tempFileDir: path.join(__dirname, "/tmp/"), abortOnLimit:true, createParentPath:true, limits: { fieldSize: 50 * 2024 * 1024 }, }) ); Error Response 2022-10-02T23:44:58.121Z 5f07668c-1c7f-47db-b11f-01f871cec353 ERROR Uncaught Exception {"errorType":"Error","errorMessage":"ENOENT: no such file or directory, mkdir '/var/task/tmp'","code":"ENOENT","errno":-2,"syscall":"mkdir","path":"/var/task/tmp","stack":["Error: ENOENT: no such file or directory, mkdir '/var/task/tmp'"," at Object.mkdirSync (fs.js:1014:3)"," at checkAndMakeDir (/var/task/node_modules/express-fileupload/lib/utilities.js:144:38)"," at module.exports (/var/task/node_modules/express-fileupload/lib/tempFileHandler.js:14:3)"," at Multipart. (/var/task/node_modules/express-fileupload/lib/processMultipart.js:63:9)"," at Multipart.emit (events.js:400:28)"," at HeaderParser.cb (/var/task/node_modules/busboy/lib/types/multipart.js:358:14)"," at HeaderParser.push (/var/task/node_modules/busboy/lib/types/multipart.js:162:20)"," at SBMH.ssCb [as _cb] (/var/task/node_modules/busboy/lib/types/multipart.js:394:37)"," at feed (/var/task/node_modules/streamsearch/lib/sbmh.js:219:14)"," at SBMH.push (/var/task/node_modules/streamsearch/lib/sbmh.js:104:16)"]} Unknown application error occurred

mohit-kumar-singh55 commented 1 year ago

Having same problem. Did you got the solution?

Trinity6264 commented 1 year ago

Having same problem. Did you got the solution?

Yeah bro, I solved it by using multer...

RomanBurunkov commented 10 months ago

It more looks like access problem. Folder /var/ can be not available for user running the app. Usually for var folder rights looks like this: drwxr-xr-x 13 root root, so, it is read only for non root.

Closing since it doesn't have enough details and I do not able to reproduce this if user allow to write into a folder.