Skip to main content
Deno 2 is finally here 🎉️
Learn more

Dewnload

Yet another Deno library for downloading files from URL.

CI

Usage

import {
  download,
  downloadMultiple,
} from "https://deno.land/x/dewnload/mod.ts";

const url = "https://picsum.photos/500/300";

download(url, { filename: "image.png" })
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

download(url, {
  filename: "image.png",
  folder: ["..", "images", "picsum"],
})
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

downloadMultiple([url, url], {
  filename: "image.png",
  folder: ["images", "picsum"],
})
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

For more example, check tests.ts file.

Using Proxy

If you want to use proxies, you have to set url and port as an environment variable. Refer to here and here for more info.

API

Functions

download(string | URL, { options?: DownloadOptions }): Promise<Output | void>
downloadMultiple((string | URL)[], { options?: DownloadOptions }): Promise<Output[]>
// downloadMultiple function automatically adds index to the beginning of the filename.

Interfaces

interface DownloadOptions {
  filename?: string; // default: URL's last path or `file`
  folder?: string[]; // default: current directory
  overwrite?: boolean; // default: false
}

interface Output {
  filename: string;
  path: string;
  size: number;
  url: string;
}

TODO

  • Folder support
  • Multiple input support

License