I try to copy a file with pipe but after code is run there is only an empty file. In the console is no error.
const writeStream = fs.createWriteStream( newLocation); // album1/fff28042018.jpg
writeStream.on('error', function(e){console.log(e)});
const readStream = fs.createReadStream(oldLocation); // imagesource/fff.jpg
readStream.on('error', function(e){console.log(e)});
readStream.pipe(writeStream);
writeStream.close();
readStream.close();
I expect that the image from imagesource/fff.jpg to the new file album1/fff28042018.jpg is copied. But in the end i have a new empty file album1/fff28042018.jpg
before the question comes up "Yes the source file exists".