云盘
志元云盘
备份云盘
Home
/
志元云盘
/
webdav
/
home
/
jcore
/
web
/
front_end
/
node_modules
/
download
File
OriginalPic
Thumbnails
CopyAllDownloadUrl
EditTime
Size
node_modules
2024-01-09 19:03:44
14.07 KB
index.js
2018-07-11 19:48:17
2.9 KB
license
2018-07-11 19:48:17
1.09 KB
package.json
2018-07-11 19:53:03
928 B
readme.md
2018-07-11 19:48:17
1.63 KB
# download [](https://travis-ci.org/kevva/download) > Download and extract files *See [download-cli](https://github.com/kevva/download-cli) for the command-line version.* ## Install ``` $ npm install download ``` ## Usage ```js const fs = require('fs'); const download = require('download'); download('http://unicorn.com/foo.jpg', 'dist').then(() => { console.log('done!'); }); download('http://unicorn.com/foo.jpg').then(data => { fs.writeFileSync('dist/foo.jpg', data); }); download('unicorn.com/foo.jpg').pipe(fs.createWriteStream('dist/foo.jpg')); Promise.all([ 'unicorn.com/foo.jpg', 'cats.com/dancing.gif' ].map(x => download(x, 'dist'))).then(() => { console.log('files downloaded!'); }); ``` ## API ### download(url, [destination], [options]) Returns both a `Promise
` and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with [additional events](https://github.com/sindresorhus/got#streams-1). #### url Type: `string` URL to download. #### destination Type: `string` Path to where your file will be written. #### options Type: `Object` Same options as [`got`](https://github.com/sindresorhus/got#options) and [`decompress`](https://github.com/kevva/decompress#options) in addition to the ones below. ##### extract Type: `boolean`
Default: `false` If set to `true`, try extracting the file using [`decompress`](https://github.com/kevva/decompress). ##### filename Type: `string` Name of the saved file. ##### proxy Type: `string` Proxy endpoint. ## License MIT © [Kevin Mårtensson](https://github.com/kevva)
2025-09-02 06:36:21 Tuesday 216.73.216.107 Runningtime:0.015s Mem:1.48 MB