request(src).pipe(fs.createWriteStream('./img/'+img_filename));
How to know that the picture has been written successfully? Instead of connecting successfully?
var writeStream = fs.createWriteStream('./img/'+img_filename); request(src).pipe(writeStream); readStream.on('end', function() { // 当没有数据时,关闭数据流 writeStream.end(); });
Listen to the event of fs.createWriteStream
Listen to the event of fs.createWriteStream