Callback function after image has downloaded

断了今生、忘了曾经 提交于 2019-12-02 21:59:35

You want to create the stream ahead of time and then do something on the close event.

var picStream = fs.createWriteStream('doodle.png');
picStream.on('close', function() {
  console.log('file done');
});
request('http://google.com/images/logos/ps_logo2.png').pipe(picStream); 

This should do it.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!