New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

easy-downloader

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-downloader

A promise based library for downloading file

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Easy Downloader

Latest Stable Version Node Version Build Status Test Coverage Maintainability Code Style: Prettier License

A promised based library for downloading file.

Install

$ npm install easy-downloader

Usage

const EasyDownloader = require('easy-downloader');

EasyDownloader.download({ uri: 'httpbin.org/image/png', destination: 'test.png' })
  .then(destination => console.log(`File is downloaded to: ${destination}`))
  .catch(e => console.error(e.message));

API

EasyDownloader.download({
    uri, destination,
    [method, encoding, data, formData, headers, auth]
});
Required Parameters:
  • uri (String): The URI of the file that you want to download.
  • destination (String): The path where your downloaded file will be written.
Optional Parameters:
  • method (String): The HTTP request method, default to GET.
  • encoding (String): Character encoding that will be used to interpret the response from the target URI. Check the Buffer documentation for more information.
  • data (Object): Request body that needs to be sent as JSON formatted data.
  • formData (Object): Request body that needs to be sent in x-www-form-urlencoded format.
  • headers (Object): Request headers that need to sent.
  • auth (Object): HTTP basic authentication credentials, you have to pass the username and password properties like so: { username: 'john', password: 'secret' }.

Note that data and formData are only applicable for request methods 'PUT', 'POST', and 'PATCH'. Also the Content-Type and Content-Length headers will be automatically provided for you.

Example
EasyDownloader.download({
    uri: 'http://example.com/download',
    destination: 'test.txt',
    method: 'POST',
    encoding: 'utf8',
    formData: {
      foo: 'bar'
    },
    headers: {
      'X-Powered-By': 'Easy Downloader'
    },
    auth: {
      username: 'john',
      password: 'secret'
    }
  })
  .then(destination => console.log(`File is downloaded to: ${destination}`))
  .catch(e => console.error(e.message));

License

MIT © Risan Bagja Pradana

Keywords

FAQs

Package last updated on 24 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc