下载并解压缩文件
下载 [](https://travis-ci.org/kevva/download) 下载并解压缩文件 请参阅 download-cli 以获取命令行版本。 安装 $ npm install download 使用 js const fs = require('fs'); const download = require('download'); (async () = { await download('http://unicorn.com/foo.jpg', 'dist'); fs.writeFileSync('dist/foo.jpg', await download('http://unicorn.com/foo.jpg')); download('unicorn.com/foo.jpg').pipe(fs.createWriteStream('dist/foo.jpg')); await Promise.all([ 'unicorn.com/foo.jpg', 'cats.com/dancing.gif' ].map(url = download(url, 'dist'))); })(); 代理 要使用代理,请阅读 got 文档。 API download(url, destination?, options?) 返回一个 Promise 和一个带有额外事件的双向流。 url 类型: string 要下载的 URL。 destination 类型: string 要写入文件的路径。 options 类型: Object 与 got 相同,此外还包括以下选项。 extract 类型: boolean 默认值: false 如果设置为 true,则尝试使用 decompress 解压缩文件。 filename 类型: string 保存的文件的名称。
暂无开放 Issues,或尚未同步最近议题。