File and Directory Entries API support in Firefox - Web APIs 编辑

Non-standard

This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The original File System API was created to let browsers implement support for accessing a sandboxed virtual file system on the user's storage device. Work to standardize the specification was abandoned back in 2012, but by that point, Google Chrome included its own implementation of the API. Over time, a number of popular sites and Web applications came to use it, often without providing any means of falling back to standard APIs or even checking to be sure the API is available before using it. Mozilla instead opted to implement other APIs which can be used to solve many of the same problems, such as IndexedDB; see the blog post Why no FileSystem API in Firefox? for more insights.

This has caused a number of popular web sites not to work properly on browsers other than Chrome. Because of that, an attempt was made to create a spec offering the features of Google's API which consensus could be reached on. The result was the File and Directory Entries API. This subset of the API provided by Chrome is still not fully specified; however, for web compatibility reasons, it was decided to implement a subset of the API in Firefox; this was introduced in Firefox 50.

This article describes how the Firefox implementation of the File and Directory Entries API differs from other implementations and/or the specification.

Chrome deviations from the specification

The largest compatibility issue still remaining is that Chrome is still using older names for many of the interfaces in the API, since they implemented a related but different specification:

Name in specificationName in Google Chrome
FileSystemDirectoryEntryDirectoryEntry
FileSystemDirectoryEntrySyncDirectoryEntrySync
FileSystemDirectoryReaderDirectoryReader
FileSystemDirectoryReaderSyncDirectoryReaderSync
FileSystemEntryEntry
FileSystemEntrySyncEntrySync
FileSystemFileEntryFileEntry
FileSystemFileEntrySyncFileEntrySync

Be sure to account for this in your code by allowing for both names. Hopefully Chrome will be updated soon to use the newer names!

To ensure your code will work in both Chrome and other browsers, you can include code similar to the following:

var FileSystemDirectoryEntry = window.FileSystemDirectoryEntry || window.DirectoryEntry;
var FileSystemEntry = window.FileSystemEntry || window.Entry;

Limitations in Firefox

Next, let's look at limitations of the Firefox implementation of the API. In broad strokes, those limitations can be summarized as follows:

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:38 次

字数:7154

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文