最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Browser-side JS: File System API vs File System Access API? - Stack Overflow

programmeradmin0浏览0评论

There was a File System API but shown as deprecated now:

There is now another, 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 mon browsers?

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

There is now another, File System Access API:
https://developer.mozilla/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 mon browsers?

Share Improve this question edited Aug 9, 2024 at 11:59 VLAZ 29.1k9 gold badges63 silver badges84 bronze badges asked May 1, 2021 at 9:51 Dan DDan D 8,6617 gold badges45 silver badges79 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

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/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/en-US/docs/Web/API/File_System_Access_API

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

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 weles corrections)

File-related APIs

API "A"

Names seen used:

  • File System API: MDN page
  • (Native File System): GitHub summary ment

Components:

  • File System Access API: W3C page, MDN page
  • Origin Private File System: MDN page

Description:

  • Apparently the remended 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 ponent, 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 ment.
  • 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:

  • File API: MDN page

Description:

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

API "D" [deprecated]

Names seen used:

  • Storage Foundation API: Chrome page, GitHub repo

Description:

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

Other storage APIs

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

  • Cookies: MDN page
  • Local storage: MDN page
  • Session storage: MDN page
  • Shared storage: MDN page
  • IndexedDB: MDN page
  • WebSQL [deprecated]: W3C page
发布评论

评论列表(0)

  1. 暂无评论