1.0.1 • Published 2 years ago

world-downloader v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Node Image Downloader

Install

npm install --save world-downloader

Options

  • url (required) - the image URL to download
  • dest (required) - the image destination. Can be a directory or a filename. If a directory is given, ID will automatically extract the image filename from options.url (see usage bellow)
  • extractFilename - boolean indicating whether the image filename will be automatically extracted from options.url or not. Set to false to have options.dest without a file extension for example. (default: true)
  • headers - HTTP headers (default: {})
  • timeout - milliseconds before a request times out
  • maxRedirects - the maximum number of allowed redirects; if exceeded, an error will be emitted. (default: 21)

For advanced options, see Node.js http.request()'s options documentation

Usage

Download to a directory and save with an another filename

const worldDl = require('world-downloader');

options = {
  url: 'http://someurl.com/image2.jpg',
  dest: '/path/to/dest/photo.jpg',     // will be saved to /path/to/dest/photo.jpg
};

worldDl.image(options)
  .then(({ filename }) => {
    console.log('Saved to', filename); // saved to /path/to/dest/photo.jpg
  })
  .catch((err) => console.error(err));

License

Under the MIT license. See LICENSE file for more details.

1.0.1

2 years ago

1.0.0

2 years ago