download
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/download package

8.0.0 • Public • Published

download Build Status

Download and extract files

See download-cli for the command-line version.

Install

$ npm install download

Usage

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')));
})();

Proxies

To work with proxies, read the got documentation.

API

download(url, destination?, options?)

Returns both a Promise<Buffer> and a Duplex stream with additional events.

url

Type: string

URL to download.

destination

Type: string

Path to where your file will be written.

options

Type: Object

Same options as got and decompress in addition to the ones below.

extract

Type: boolean
Default: false

If set to true, try extracting the file using decompress.

filename

Type: string

Name of the saved file.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
8.0.0218,442latest
4.0.1-rc.13rc

Version History

VersionDownloads (Last 7 Days)Published
8.0.0218,442
7.1.0794,847
7.0.07,461
6.2.5614,023
6.2.413
6.2.34
6.2.24
6.2.13
6.2.010
6.1.03
6.0.06
5.0.324,580
5.0.23,247
5.0.16
5.0.09
4.4.363,271
4.4.25
4.4.171
4.3.04
4.2.17
4.2.06
4.1.49
4.1.33
4.1.211
4.1.19
4.1.05
4.0.15
4.0.09
4.0.1-rc.13
3.3.03,750
3.2.033
3.1.27
3.1.14
3.1.04
3.0.146
3.0.04
2.0.06
1.0.7191
1.0.66
1.0.53
1.0.45
1.0.36
0.1.191,726
1.0.25
1.0.17
1.0.05
0.2.428
0.2.34
0.2.25
0.2.16
0.2.07
0.1.185
0.1.173
0.1.165
0.1.154
0.1.146
0.1.135
0.1.124
0.1.118
0.1.104
0.1.93
0.1.84
0.1.75
0.1.63
0.1.55
0.1.46
0.1.35
0.1.25
0.1.15
0.1.05

Package Sidebar

Install

npm i download

Weekly Downloads

1,732,024

Version

8.0.0

License

MIT

Unpacked Size

6.07 kB

Total Files

4

Last publish

Collaborators

  • shinnn
  • kevva
  • silverwind