node.js - Problem with request's pipe method
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-16 13:33:45
0
2
672
 request(src).pipe(fs.createWriteStream('./img/'+img_filename));

How to know that the picture has been written successfully? Instead of connecting successfully?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(2)
巴扎黑
var writeStream = fs.createWriteStream('./img/'+img_filename);
request(src).pipe(writeStream);
readStream.on('end', function() { // 当没有数据时,关闭数据流
    writeStream.end();
});
巴扎黑

Listen to the event of fs.createWriteStream

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template