Socket
Socket
Sign inDemoInstall

async-get-file

Package Overview
Dependencies
5
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    async-get-file

A wrapper around download-file package to make it return a promise.


Version published
Weekly downloads
346
increased by35.16%
Maintainers
1
Install size
1.02 MB
Created
Weekly downloads
 

Readme

Source

async-get-file : Download files with Promise (Node.js)

npm npm NPM

This package is a wrapper around the download-file package replacing callback functions with functions that return a Promise.

Basically it lets you write code like this

await get(url,options);
console.log("Success");

instead of

get(url, options, err => {
    if (err) throw err;
    console.log("Success");
}) 

Installation

NPM

Basic Usage

const async = require("async");
const get = require("async-get-file");

async function main(){
  var url = "http://i.imgur.com/G9bDaPH.jpg";
  var options = {
    directory: "./images/cats/",
    filename: "cat.gif"
  }
  await get(url,options);
}

main();

Or

const Promise = require("promise");
const get = require("async-get-file");

var url = "http://i.imgur.com/G9bDaPH.jpg";
var options = {
  directory: "./images/cats/",
  filename: "cat.gif"
  }

get(url,options)
.catch(err => {
      console.log(err);
      });

API

get(url, [options])

  • url string of the file URL to download

  • options object with options

    • directory string with path to directory where to save files (default: current working directory)
    • filename string for the name of the file to be saved as (default: filename in the url)
    • timeout integer of how long in ms to wait while downloading (default: 20000)

References

License

async-get-file is published under the MIT license. For more information, see the accompanying LICENSE file.

Keywords

FAQs

Last updated on 12 May 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc