1.0.0 • Published 4 years ago

downloadly v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

NodeJS package to download files easily!

You can download files from any direct link! Or even with share links from supported platforms such as Yandex.Disk!

Support for other platforms coming soon!

You need NodeJS to run this code.

Installation

Install with:

$ npm install downloadly --save for projects,

# npm install downloadly -g to use from terminal.

Example

Node

const downloadly = require('downloadly');

(async () => {
  await downloadly('https://somewhere.com/something.jpg', './something.jpg');
});

CLI

downloadly "https://somewhere.com/something.jpg" -o "./something.jpg"

More examples here.

API

downloadly(href, file_path?, options?, chunk_callback?)

Returns a Promise.

href

Type: string

URL that has file to download. It can be a share URL if service option is provided in options.

file_path

Type: string

Optional.

Path to the file that will be written on disk.

Experimental! If not given, it will download it to the dir that user is currently in.

Experimental! If filename and extension are not given, It will get filename and extension automatically.

Note

It is important to note, that relative path is started from the dir that user is currently in.

You can use __dirname Node variable to get the dir that current script is in.

options

Type: Object

Optional.

Options for downloadly function.

It takes following properties,

KeyTypeDefaultPossible ValuesDescription
servicestring'web''web', 'yandex.disk'Service that will be used to download.

chunk_callback

Type: function

Optional.

A function that will be called for every chunk downloaded.

It calls the function with following parameters,

ParameterTypeDescription
errErrorError if given.
total_byteintTotal byte of the file that will be downloaded.
received_byteintTotal received byte of the file that will be downloaded.