fs.createReadStream() equivalent for remote file in Node

后端 未结 2 1009
面向向阳花
面向向阳花 2020-12-28 15:11

Is there an equivelate method to fs.createReadStream() in Node for remote files? Using as follows throws Unhandled \'error\' event

var s = fs.cr         


        
2条回答
  •  心在旅途
    2020-12-28 15:47

    Node is no PHP :)

    Use the request module:

    request('http://fromrussiawithlove.com/baby.mp3').pipe(fs.createWriteStream('song.mp3'))
    

提交回复
热议问题