Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

Web File System Access, File Handlers, and Origin Private Storage

How web apps and extensions read local files, register file handlers, and use the origin-private file system, with limits and verification.

This page summarises Chrome for Developers documentation on how sites and extensions work with files: the File System Access API for user-chosen paths, the Origin Private File System (OPFS) for fast private storage, the File Handling API for installed web apps, and ChromeOS extension APIs such as file_browser_handlers and fileSystemProvider. Cloudflare Workers exposes a related virtual file system behind a compatibility flag—not the same as opening files on a visitor’s laptop.

File System Access API: read and save on the user’s device

Section titled “File System Access API: read and save on the user’s device”

The File System Access API lets a web app, after the user grants access, read or save changes directly to files and folders on the device, enumerate directory contents, and build open→edit→save flows that <a download> cannot provide.

The File System Access API allows web apps to read or save changes directly to files and folders on the user’s device.

— Google, The File System Access API: simplifying access to local files

It is not the legacy FileSystem surface from drag-and-drop or <input type="file">, and not the deprecated sandboxed directory API. On capabilities, Google describes the same idea in one line: allow web apps to read or save changes directly to files and folders on the user’s device.

When to call showOpenFilePicker and showSaveFilePicker

Section titled “When to call showOpenFilePicker and showSaveFilePicker”

Entry points are window.showOpenFilePicker(), window.showSaveFilePicker(), and window.showDirectoryPicker(). They must run in a secure context and from a user gesture; otherwise you may see SecurityError: Must be handling a user gesture to show a file picker.

Feature detection:

if ('showOpenFilePicker' in self) {
// Picker API is available.
}

After the user picks a file, keep the FileSystemFileHandle for later saves. Read contents with handle.getFile() then file.text(), arrayBuffer(), or stream(). If the file on disk changes, call getFile() again because the cached File may become unreadable.

Writing uses createWritable(), write(), and close(); data is not persisted until the stream closes. For an existing file the user only granted read access to, createWritable() triggers a write permission prompt on a further user gesture (for example Save).

Handles are serializable—you can store them in IndexedDB (as in cache models in the browser) and restore them on the next visit. Permissions are not always persisted: call queryPermission() and, if needed, requestPermission() (often with { mode: 'readwrite' } when you need write).

The browser-fs-access library is a progressive-enhancement helper: it uses native pickers when present and falls back to <input type="file"> or download links when not—useful when you must support Safari or mobile without a full polyfill.

Approach User sees real paths Overwrite existing file Works without Chromium desktop
File System Access API pickers Yes Yes (with permission) Limited (see browser support in docs)
<input type="file"> / download Partial No (new download) Widely
OPFS (navigator.storage.getDirectory()) No (private to origin) N/A (app storage) Growing (see OPFS section)

Origin private file system (OPFS): fast storage without exposing paths

Section titled “Origin private file system (OPFS): fast storage without exposing paths”

OPFS is private to the page origin: users do not browse it like a normal folder, but you get directory handles and files optimized for performance (including synchronous access handles in workers via createSyncAccessHandle() as described in accessing files optimized for performance).

The Origin Private File System (OPFS) is a comparatively young standard for a storage endpoint. It’s private to the origin of the page, and thus is invisible to the user, unlike the regular file system.

— Google, Cache models in the browser

Typical pattern:

const root = await navigator.storage.getDirectory();
const handle = await root.getFileHandle('model.bin', { create: true });
const writable = await handle.createWritable();
await blob.stream().pipeTo(writable);

Use OPFS for large blobs (models, media chunks, databases) where you do not need the user to pick a path. Use the File System Access API when the user must choose or keep a specific file on disk. The two approaches can coexist—for example cache in OPFS while also opening a user-selected file via a persisted handle.

The Storage Foundation API was abandoned; Google directs new work to OPFS under the File System Access API instead.

File Handling API: open files with an installed web app

Section titled “File Handling API: open files with an installed web app”

The File Handling API registers an installed app with the OS so users can double-click or use “Open with…” on supported types.

Register an app as a file handler with the operating system.

— Google, Let installed web applications be file handlers

Declare handlers in the web app manifest with action, accept (MIME type → extensions), optional icons, and launch_type (single-client vs multiple-clients). Without installation, registration has no effect.

At runtime, use the Launch Handler API:

if ('launchQueue' in window && 'files' in LaunchParams.prototype) {
launchQueue.setConsumer(async (launchParams) => {
const fileHandle = launchParams.files[0];
// Use File System Access API patterns to read the file.
});
}

File Handling is currently limited to desktop operating systems in the docs. A permission prompt appears when a PWA opens a file until the user allows, blocks, or ignores it three times (then Chromium embargoes the permission). Changing file_handlers in the manifest resets permissions.

Alternatives when File Handling is unavailable: Web Share Target for share-sheet delivery, or drag-and-drop with the File System Access API in an already-open app.

ChromeOS extensions: three different “file” integrations

Section titled “ChromeOS extensions: three different “file” integrations”

ChromeOS adds extension-specific wiring beyond standard web APIs. Optional manifest keys are listed under manifest file format.

Mechanism Purpose Main manifest / API
file_handlers Extension page opens types from Files app menus file_handlers + Launch Handler API
file_browser_handlers Buttons in the ChromeOS file browser (Alt+Shift+M, removable media) file_browser_handlers + fileBrowserHandler permission
fileSystemProvider Virtual volumes in Files (cloud, archives, devices) file_system_provider_capabilities + provider events

File handling on Chrome OS mirrors PWAs: handlers appear in Open / Open with when the selected extension matches. The action HTML page must load a separate script that uses launchQueue to obtain FileSystemFileHandle objects—the same pattern as the manifest file_handlers reference.

fileBrowserHandler: actions on selected files in the browser UI

Section titled “fileBrowserHandler: actions on selected files in the browser UI”

Use the chrome.fileBrowserHandler API to extend the Chrome OS file browser. For example, you can use this API to enable users to upload files to your website.

— Google, browser.fileBrowserHandler

Register with file_browser_handlers (filters like filesystem:*.png), fileBrowserHandler permission, and a 16×16 icon. Listen to browser.fileBrowserHandler.onExecute and read details.entries (FileSystemFileEntry)—ChromeOS only, foreground only.

fileSystemProvider: mount virtual file systems

Section titled “fileSystemProvider: mount virtual file systems”

Use the chrome.fileSystemProvider API to create file systems, that can be accessible from the file manager on Chrome OS.

— Google, browser.fileSystemProvider

Declare capabilities (configurable, watchable, multiple_mounts, required source: file | device | network). Mounted volumes persist across reboot until unmount or extension unload. Source file handlers require a packaged app (onLaunched); device and network mount on onMountRequested.

mime_types_handler: replace built-in viewers for full-frame documents

Section titled “mime_types_handler: replace built-in viewers for full-frame documents”

chrome.mimeHandler handles MIME streams in extensions—for example custom PDF viewers—without replacing the URL with chrome-extension:// or refetching.

Benefits over request interception include keeping the original URL, reusing Chrome’s buffered response (important for POST or single-use URLs), supporting embeds when can_embed is true, and working with file:// without extra settings.

Register in mime_types_handler:

"mime_types_handler": {
"application/pdf": {
"handler_url": "viewer.html",
"can_embed": true
}
}

As of Chrome 151 in the docs, application/pdf is the only MIME type for public handlers; unsupported types warn at install. If multiple extensions register the same type, the most recently installed wins.

In the handler page, call browser.mimeHandler.getStreamInfo(), consume streamUrl once fully, then render or call abortAndFallbackToNativeHandler() so Chrome can show the built-in viewer from its buffer when possible.

Legacy Chrome Apps and server-side virtual FS

Section titled “Legacy Chrome Apps and server-side virtual FS”

Chrome Apps used chrome.fileSystem with manifest file_handlers and onLaunched; Google states Chrome Apps are being removed—new work should use extensions plus web platform APIs or PWAs.

On Cloudflare Workers, the Web File System API exposes a virtual filesystem (same backing as node:fs in Workers) when enable_web_file_system is set—nodejs_compat is not required. Behaviour may differ from browsers because standardization is incomplete (changelog).

  • Calling file pickers without a user gesture or after async work that breaks the gesture chain.
  • Assuming read permission implies write permission on an existing handle.
  • Expecting File Handling on the open web without PWA installation (or on mobile desktop-only limits).
  • Mixing up ChromeOS file_browser_handlers (browser toolbar buttons) with manifest file_handlers (Open menus).
  • Consuming mimeHandler streamUrl partially before deciding to fall back—fallback may refetch and fail for POST bodies.
  • Storing secrets in OPFS thinking users can “find” the files on disk—they are origin-private abstractions.
  1. Confirm File System Access support with ('showOpenFilePicker' in window) and exercise open/save in a secure context over HTTPS, following The File System Access API.

  2. For a PWA, install the app, add file_handlers to the manifest, and verify “Open with” and launchQueue using File handling and the ChromeOS extension guide if you target ChromeOS extensions.

  3. On ChromeOS, test extension handlers with the flags or versions described in What’s new in Chrome extensions (ExtensionWebFileHandlers / extension-web-file-handlers).

  4. For OPFS, log read/write timings with performance.measure as in Cache models in the browser and confirm data survives reload via navigator.storage.getDirectory().

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.