🚧 WIP at beta branch
File System Access ponyfill for server side runtime.
This allows the native file dialog and the file system handle API to be used on the server side.
Complies with WICG, File System Access and File System Standard.
FileSystemAccess
binds the
File System Access API. The
constructor requires adaptor.
import { type Adaptor, FileSystemAccess } from "@miyauci/file-system-access";
declare const adaptor: Adaptor;
const { showOpenFilePicker, showDirectoryPicker } = new FileSystemAccess(
adaptor,
);
const [handle] = await showOpenFilePicker();
const writable = await handle.createWritable();
await writable.write("hello");
await writable.write("world");
await writable.close();
const file = await handle.getFile();
await file.text(); // helloworld;
Adaptor is an abstraction that absorbs runtime differences.
Adaptor for deno runtime with asynchronous BLOB.
import { DenoAdaptor } from "@miyauci/file-system-access/deno";
import { FileSystemAccess } from "@miyauci/file-system-access";
const adaptor = new DenoAdaptor();
const { showOpenFilePicker } = new FileSystemAccess(adaptor);
When using DenoAdaptor
, the following flags are required.
--unstable-ffi
It also requires the following permission.
--allow-ffi
--allow-read
(When read directory or file)--allow-write
(When write file)
// TODO
// TODO
See CONTRIBUTING.md
MIT © 2024 Tomoki Miyauchi