0

I have these code running on localhost, and everything is working perfect but later I uploaded it on GitHub and deployed on vercel, the code is working fine but the express-fileupload package is throwing an error saying can't locate tmp file/folder but I have uploaded the tmp folder on GitHub

app.use(
  "/api/v1/product",
  fileUpload({
    useTempFiles: true,
    tempFileDir: path.join(__dirname, "/tmp/"),
    abortOnLimit:true,
    preserveExtension:true,
    safeFileNames:true,
    limits: { fieldSize: 50 * 2024 * 1024 },
  })
);

Error Response

2022-10-02T23:32:08.208Z 739e6422-bd97-4c4a-88c9-afb571045399 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

TRI NI TY
  • 1
  • 1
  • 1) You shouldn't need the slashes around `tmp`. Just use `path.join(__dirname, "tmp")`. 2) Git doesn't keep empty directories. A common thing to do is to place an empty file names `.keep` or `.gitkeep` in otherwise empty directories you need present in your repo – Phil Oct 03 '22 at 01:46
  • I have added the .gitkeep file in my tmp folder but is not working same error – TRI NI TY Oct 03 '22 at 02:58

0 Answers0