Below is my code where I am trying to use fs.createReadStream that is piped into a fs.createWriteStream. Its working for one hit. But if I run the same code using concurrent hits getting error as
Error: ENOENT, no such file or directory
var fileReadStream = fs.createReadStream("test.png", {encoding: "utf16le"});
var fileWriteStream = fs.createWriteStream("test1.png", {encoding: "utf16le"});
fileReadStream.pipe(fileWriteStream);
fileReadStream.on('end', function () {
});
fileWriteStream.on('close', function () {
fileReadStream.on('finish', function () {
fs.unlink(test1.png);
})
})
I am not that good in filesystem api's. Can someone help me what I am doing wrong here.