search

Home  >  Q&A  >  body text

node.js - Problem with request's pipe method

 request(src).pipe(fs.createWriteStream('./img/'+img_filename));

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

曾经蜡笔没有小新曾经蜡笔没有小新2823 days ago667

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 13:35:45

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

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 13:35:45

    Listen to the event of fs.createWriteStream

    reply
    0
  • Cancelreply