FileSystem

这是 实验性技术
检查 浏览器兼容性表格 在生产中使用这之前。

The File and Directory Entries API interface FileSystem is used to represent a file system. These objects can be obtained from the filesystem property on any file system entry. Some browsers offer additional APIs to create and manage file systems, such as Chrome's requestFileSystem() 方法。

This interface will not grant you access to the users filesystem. Instead you will have a "virtual drive" within the browser sandbox. If you want to gain access to the users filesystem you need to invoke the user by eg. installing a Chrome extension. The relevant Chrome API can be found here .

基本概念

There are two ways to get access to a FileSystem 对象:

  1. You can directly ask for one representing a sandboxed file system created just for your web app directly by calling window.requestFileSystem() .  If that call is successful, it executes a callback handler, which receives as a parameter a FileSystem object describing the file system.
  2. You can get it from a file system entry object, through its filesystem 特性。

特性

FileSystem.name 只读
A USVString representing the file system's name. This name is unique among the entire list of exposed file systems.
FileSystem.root 只读
A FileSystemDirectoryEntry object which represents the file system's root directory. Through this object, you can gain access to all files and directories in the file system.

规范

规范 状态 Comment
文件和目录条目 API
The definition of 'FileSystem' in that specification.
草案

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
FileSystem Chrome 7
Alternate Name
7
Alternate Name
Alternate Name Uses the non-standard name: DOMFileSystem
Edge ≤18
Prefixed
≤18
Prefixed
Prefixed Implemented with the vendor prefix: WebKit
Edge only supports this API in drag-and-drop scenarios using the the DataTransferItem.webkitGetAsEntry() method. It's not available for use in file or folder picker panels (such as when you use an <input> element with the HTMLInputElement.webkitdirectory 属性。
Firefox 50 IE No Opera 15
Prefixed
15
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari 11.1 WebView Android ≤37
Alternate Name
≤37
Alternate Name
Alternate Name Uses the non-standard name: DOMFileSystem
Chrome Android 18
Alternate Name
18
Alternate Name
Alternate Name Uses the non-standard name: DOMFileSystem
Firefox Android 50 Opera Android 14
Prefixed
14
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS 11.3 Samsung Internet Android 1.0
Prefixed
1.0
Prefixed
Prefixed Implemented with the vendor prefix: webkit
name Chrome 7 Edge ≤18 Firefox 50 IE No Opera 15 Safari 11.1 WebView Android ≤37 Chrome Android 18 Firefox Android 50 Opera Android 14 Safari iOS 11.3 Samsung Internet Android 1.0
root Chrome 7 Edge ≤18 Firefox 50 IE No Opera 15 Safari 11.1 WebView Android ≤37 Chrome Android 18 Firefox Android 50 Opera Android 14 Safari iOS 11.3 Samsung Internet Android 1.0

图例

完整支持
完整支持
不支持
不支持
见实现注意事项。
使用非标名称。
要求使用供应商前缀或不同名称。
要求使用供应商前缀或不同名称。

另请参阅