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

Dewnload

Yet another DenoJS 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)); // image.png

download(url, {
  filename: "image.png",
  folder: ["images", "picsum"],
})
  .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));

API

Functions

download(string | URL, { options?: DownloadOptions }): Promise<Output>
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
}

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

TODO

  • Folder support
  • Multiple input support

License