var download = require('download-to-file')
console.log('Downloading to /tmp/example.html')
download('http://example.com/', '/tmp/example.html', function (err, filepath) {
if (err) throw err
console.log('Download finished:', filepath)
})
download(url, filepath, callback)
将下载给定的内容url并将其存储在所指定的文件中filepath。完成后,callback将使用一个可选的错误对象作为第一个参数,并filepath作为第二个参数调用。
如果服务器未返回200 HTTP状态代码,则将以错误调用回调,并且文件不会存储在磁盘上。