Dan D.
Dan D.

Reputation: 8557

Browser-side JS: File System API vs File System Access API?

There was a File System API but shown as deprecated now:
https://developer.mozilla.org/en-US/docs/Web/API/Window/requestFileSystem

There is now another, File System Access API:
https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API

What happened to the old API and why was it discontinued? Should the new File System Access API be stable in all common browsers?

Upvotes: 3

Views: 2785

Answers (2)

Venryx
Venryx

Reputation: 17959

The documentation on the file-related APIs is a real mess in my opinion. I have yet to find a definitive place that disambiguates between all the terms.

The best summary I've seen so far is probably here. But even it leaves a lot of confusion and ambiguity (eg. since it doesn't include all of the various names for the linked APIs).

So this StackOverflow answer is the place where I'll try to disambiguate between them. I haven't 100% verified every point gathered below, but it's a "best effort" summarization. (and of course welcomes corrections)

File-related APIs

API "A"

Names seen used:

Components:

Description:

  • Apparently the recommended way to store large amounts of local data.
  • Also provides a way to access "actual files" on the user's drive, if user grant's permission. (not necessary if only using the Origin Private File System component, which doesn't require user permissions since sandboxed)

API "B"

Names seen used:

  • FileSystem API: MDN page (nav-bar says "Web APIs -> FileSystem")
  • File and Directory Entries API: MDN page (table-of-contents header)
  • File API: Directories and System: W3C page (page title)

Description:

  • At least part of this API (the window.requestFileSystem function) seems to have been deprecated, but is still in use, eg. by Github, as per this comment.
  • However, the rest (or at least most) of this API is still active/non-deprecated. For example, it is used for reading the contents of dragged-and-dropped folders/file-trees.

API "C"

Names seen used:

Description:

  • Basic file structures; used by some of the higher level APIs.

API "D" [deprecated]

Names seen used:

Description:

  • Now deprecated / abandoned.
  • Experimental; was usable in chrome behind a flag.

Other storage APIs

These don't deal with "files" specifically, but for comprehensiveness, these are other APIs for storage that are usable from web APIs:

Upvotes: 2

Dan D.
Dan D.

Reputation: 8557

It turned out that File System Access API is not deprecated, it's just not standardised (May 2021); the deprecated one is the function window.requestFileSystem; the same function on Chromium-based browsers is window.webkitRequestFileSystem.

File System API is for creating a virtual drive (temporary or persistent) for each website when using browser-based db (IndexedDB) is not necessary especially for the purpose of storing files.
https://developer.mozilla.org/en-US/docs/Web/API/FileSystem

File System Access API is different, it is for accessing the real file system of the OS. This API is now standardised and available on Chromium-based browsers (May 2021). Firefox has not yet adapted this API.
https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API

Status of these APIs: https://developer.mozilla.org/en-US/docs/Web/API

Upvotes: 7

Related Questions