downloadly

NodeJS package to download files easily!

Usage no npm install needed!

<script type="module">
  import downloadly from 'https://cdn.skypack.dev/downloadly';
</script>

README

downloadly

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,

Key Type Default Possible Values Description
service string '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,

Parameter Type Description
err Error Error if given.
total_byte int Total byte of the file that will be downloaded.
received_byte int Total received byte of the file that will be downloaded.