fs.mkdir ( ./tmp ) is giving error #10196
Answered
by
TooTallNate
Abhijeet-2003
asked this question in
Help
-
Problem DescriptionI'm making the /tmp folder to store the incoming PDF from the client. const storage = multer.diskStorage({
destination: (req, file, cb) => {
fs.mkdir('./tmp', { recursive: true }, (error) => {
if (error) {
console.error('Error creating folder:', error);
} else {
console.log('Folder created successfully');
}
cb(null, './tmp');
});
},
filename: (req, file, cb) => {
console.log("File uploaded");
console.log(file);
cb(null, `${file.originalname}`);
}
}); After doing all the operations, I'm deleting the /tmp folder const folderPath = `./tmp`;
if( fs.existsSync(folderPath) ){
fs.rm(folderPath, {recursive: true}, (error) => {
if (error) {
console.error('Error deleting tmp folder', error);
res.status(500).send('Error deleting tmp folder');
} else {
console.log('tmp folder deleted successfully');
res.status(200).send('tmp folder deleted successfully');
// res.status(200).send('Original file deleted');
}
});
} The vercel server logs are showing this error
|
Beta Was this translation helpful? Give feedback.
Answered by
TooTallNate
Jul 11, 2023
Replies: 1 comment 1 reply
-
Use |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Abhijeet-2003
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
/tmp
, not./tmp
.