Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TomokiMiyauci/file-system-access

file-system-access

🚧 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.

Usage

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;

Adaptors

Adaptor is an abstraction that absorbs runtime differences.

Deno

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)

Node

// TODO

Bun

// TODO

Contributing

See CONTRIBUTING.md

License

MIT Β© 2024 Tomoki Miyauchi

About

File System Access, based on WICG spec reference implementation

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /