import { createWritableStream } from "https://deno.land/x/ayonli_jsext@v0.9.72/fs.ts";
Creates a writable stream for the target file.
NOTE: In Node.js, this function requires Node.js v18.0 or above.
Examples
Example 1
Example 1
// with the default storage
import { createWritableStream } from "@ayonli/jsext/fs";
const output = createWritableStream("/path/to/file.txt");
const res = await fetch("https://example.com/file.txt");
await res.body!.pipeTo(output);
Example 2
Example 2
// with a user-selected directory as root (Chromium only)
import { createWritableStream } from "@ayonli/jsext/fs";
const root = await window.showDirectoryPicker();
const output = createWritableStream("/path/to/file.txt", { root });
const res = await fetch("https://example.com/file.txt");
await res.body!.pipeTo(output);
Parameters
optional
options: Omit<WriteFileOptions, "signal"> = [UNSUPPORTED]Returns
WritableStream<Uint8Array>