Error: ENOENT, no such file or directory - fs.createReadStream that is piped into a fs.createWriteStream
10,796
Add __dirname + '/test.png' that fixed my error
var fileReadStream = fs.createReadStream(__dirname + <path to image From current directory>, {encoding: "utf16le"});
var fileWriteStream = fs.createWriteStream(__dirname + <path to image From current directory>, {encoding: "utf16le"});
Author by
user4324324
Updated on June 27, 2022Comments
-
user4324324 almost 2 years
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.
-
Abhishek Bhagate almost 4 yearsWhenever you answer, try to be as clear about it as possible.