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

x/ayonli_jsext/dialog/index.ts>saveFile

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

Saves a file 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.

Examples

Example 1

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

const file = new File(["Hello, World!"], "hello.txt", { type: "text/plain" });

await saveFile(file);

Parameters

file: File
optional
options: Pick<SaveFileOptions, "title">

Returns

Promise<void>

Examples

Example 1

import { saveFile } from "@ayonli/jsext/dialog";
import bytes from "@ayonli/jsext/bytes";

const data = bytes("Hello, World!");

await saveFile(data, { name: "hello.txt", type: "text/plain" });

Parameters

file:
| Blob
| ArrayBuffer
| ArrayBufferView
| ReadableStream<Uint8Array>
optional
options: SaveFileOptions

Returns

Promise<void>