download

Download and extract files effortlessly

download

Download and extract files effortlessly

$ npm install --save download

If you're fetching an archive you can set extract: true in options and it'll extract it for you.

var Download = require('download');
 
new Download({mode: '755'})
    .get('http://example.com/foo.zip')
    .get('http://example.com/cat.jpg')
    .dest('dest');
    .run(function (errfiles) {
        console.log(files);
        //=> [{path: 'foo.zip', url: 'http://example.com/foo.zip', contents: <Buffer 50 4b 03>, ...}, ...] 
    });

Creates a new Download instance.

Type: object

Options for got or the underlying http/https request can be specified, as well as options specific to the download module as described below.

Type: boolean
Default: false

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

Type: string

Set mode on the downloaded file, i.e {mode: '755'}.

Type: number
Default: 0

Remove leading directory components from extracted files.

Type: string

Add a URL to download.

Type: string

Set an optional destination folder that will take precedence over the one set in .dest().

Type: string

Set the destination folder to where your files will be downloaded.

Type: function or string

Rename your files using gulp-rename.

Type: function

Add a plugin to the middleware stack.

The response object.

The requested URL.

Type: function

Contains an array of vinyl files.

$ npm install --global download
$ download --help
 
  Usage
    $ download <url>
    $ download <url> > <file>
    $ download --out <directory> <url>
    $ cat <file> | download --out <directory>
 
  Example
    $ download http://foo.com/file.zip
    $ download http://foo.com/cat.png > dog.png
    $ download --extract --strip 1 --out dest http://foo.com/file.zip
    $ cat urls.txt | download --out dest
 
  Options
    -e, --extract           Try decompressing the file
    -o, --out               Where to place the downloaded files
    -s, --strip <number>    Strip leading paths from file names on extraction

MIT © Kevin Mårtensson