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

x/ayonli_jsext/dialog/file.ts>downloadFile

A JavaScript extension package for building strong and modern applications.
Latest
function downloadFile
import { downloadFile } from "https://deno.land/x/ayonli_jsext@v0.9.72/dialog/file.ts";

Downloads the file of the given URL to the file system.

In the CLI, this function will open a dialog to let the user choose the location where the file will be saved. In the browser, the file will be saved to the default download location, or the browser will prompt the user to choose a location.

NOTE: This function depends on the Fetch API and Web Streams API, in Node.js, it requires Node.js v18.0 or above.

Examples

Example 1

import { downloadFile } from "@ayonli/jsext/dialog";

await downloadFile("https://ayonli.github.io/jsext/README.md");

Parameters

url: string | URL
optional
options: DownloadFileOptions = [UNSUPPORTED]

Returns

Promise<void>