https://github.com/arghyadeep-k/async-get-file
A wrapper around download-file package to make it return a promise.
https://github.com/arghyadeep-k/async-get-file
async download files npm package promise wrapper
Last synced: 3 months ago
JSON representation
A wrapper around download-file package to make it return a promise.
- Host: GitHub
- URL: https://github.com/arghyadeep-k/async-get-file
- Owner: arghyadeep-k
- License: mit
- Created: 2020-01-10T20:27:57.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T05:38:51.000Z (about 2 years ago)
- Last Synced: 2025-02-01T12:11:16.558Z (4 months ago)
- Topics: async, download, files, npm, package, promise, wrapper
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/async-get-file
- Size: 35.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# async-get-file : Download files with Promise (Node.js)

[](https://sonarcloud.io/dashboard?id=arghyadeep-k_async-get-file)







[](https://ko-fi.com/arghyadeep)This package is a wrapper around the [download-file](https://www.npmjs.com/package/download-file) package replacing callback functions with functions that return a Promise.
Basically it lets you write code like this
```javascript
await get(url,options);
console.log("Success");
```
instead of
```javascript
get(url, options, err => {
if (err) throw err;
console.log("Success");
})
```## Installation
[](https://nodei.co/npm/async-get-file/)
**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
```javascript
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
```javascript
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](https://github.com/arghyadeep-k/google-sheets-logger) the project on Github.And, if you are willing to [buy me a coffee](https://ko-fi.com/arghyadeep), that would be awesome. :)