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

x/ayonli_jsext/fs.ts>readFileAsFile

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

Reads the file as a File object.

NOTE: This function can also be used in Cloudflare Workers.

Examples

Example 1

// with the default storage
import { readFileAsFile } from "@ayonli/jsext/fs";

const file = await readFileAsFile("/path/to/file.txt");

Example 2

// with a user-selected directory as root (Chromium only)
import { readFileAsFile } from "@ayonli/jsext/fs";

const root = await window.showDirectoryPicker();
const file = await readFileAsFile("/path/to/file.txt", { root });

Parameters

target: string | FileSystemFileHandle
optional
options: ReadFileOptions = [UNSUPPORTED]

Returns

Promise<File>