I have a problem but I don't know how to solve it. I reading a file from s3, then I save it to a folder(downloads). After that, I read the file that I saved in the folder (that I saved in downloads) and re-size it + save it in a different folder with a different name (resized). Then, I want to read again this file in order to upload it again in its the new size but when I try to do that it throws an error that there is no such file in this directory but when I check it in my folder it dose. My guess it's trying to read before the image is written in the new folder (resized) How can I fix it?
update
so accroding to commits this is what I did but it disen't print out anything in fs.readFileAsync. Why?
var image = new ImageResize(__dirname +'/../downloads/'+ hash + '.png');
image.smartResizeDown({
width: 200,
height: 200
}).then(function () {
image.stream(function (err, stdout, stderr) {
var writeStream = fs.createWriteStream(__dirname +'/../resized/'+ hash + 'resize.png');
stdout.pipe(writeStream);
}).then(function(){
fs.readFileAsync('C:/Users/user/Desktop/cloud/new/resized/'+hash+'resize.png', function(error, buf){
if(error)
console.log(error);
else
console.log('yay');
});
});
});