Can someone help with this problem, I know that there are a lot of questions related to this problem but I have tried almost everything, nothing helps.
makeFile(dirName, fileName, content, callback) {
if (!fs.existsSync(dirName)) {
// fs.mkdirSync(dirName, {recursive: true});
shell.mkdir('-p', dirName);
}
zlib.inflate(Buffer.from(content), (err, InfoInflated) => {
if (err) {
logger.error(err);
return callback({ success: false, code: 500, err: err});
}
let file = fs.createWriteStream(dirName + fileName, {
flags: 'a'
});
file.on('open', fd => {
file.write(InfoInflated.toString('utf8'));
file.end();
}).on('error' , (err) => {
logger.error(err);
return callback({ success: false, code: 500, err: err});
}).on('finish', () => {
logger.info("file is complete !");
return callback({success: true, code: 200, result: {message: "OK", file: dirName + fileName}});
});
});
}
/tmp/files/2019-02-05/1205_undefined_undefined/1205_undefined_undefined.zip' this is the full path which creates an error
fs.createWriteStream(dirName + fileName, ...- please edit your post and show us the values ofdirNameandfileName. Also show us where exactly in your code the error gets raised.makeFilefunction? Please show us a minimal reproducible example so we can try to replicate your situation. The value ofdirNameandfileNameare likely important, as is whether the directories you have indirNamealready exist. If they don't all exist,createWriteStreamwill fail withENOENT(which isfile or directory not found).