A wrapper around download-file package to make it return a promise. https://www.npmjs.com/package/async-get-file
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Arghyadeep Kundu fcdd6f9689
Added CI workflow for GPR branch
8 months ago
.github Added CI workflow for GPR branch 8 months ago
.gitignore Added code 1 year ago
LICENSE Initial commit 1 year ago
README.md Added CI workflow and updated dependencies 8 months ago
index.js Renamed async-download-file to async-get-file 1 year ago
package-lock.json Updated package.json 11 months ago
package.json Added CI workflow and updated dependencies 8 months ago
sonar-project.properties Added CI workflow and updated dependencies 8 months ago

README.md

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

CI Quality Gate Status npm npm bundle size Libraries.io SourceRank Depfu Snyk Vulnerabilities for npm package 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

Install from command line:

npm install --save async-get-file

Or

Install via package.json:

Add the following to your package.json file under dependencies

"async-get-file": "1.0.2"

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.




PS:

If you find this package useful, please star the project on Github.

And, if you are willing to buy me a coffee, that would be awesome. :)