FileSystemAccess: This is used for Google Chrome and Edge, and possibly other browsers, under secure context.
FileEntry: This is used for Firefox when the FS is mounted through a drag-and-drop interface.
File: This is used for Firefox when the FS is mounted by a directory picker dialog
The implementation is also chosen in this order and the first supported one is selected. If you are on Chrome/Edge and FileSystemAccess is not used, you can use isSecureContext to narrow down the reason.
If you are wondering why Safari is not mentioned, it's because Apple made it so I have to buy a Mac to test, which I didn't.
After you get an instance of FsFileSystem, you can use capabilities to inspect
what is and is not supported.
See FsCapabilities for more info. This is the support matrix:
Implementation
write?
live?
FileSystemAccess
Yes*
Yes
FileEntry
No
Yes
File
No
No
* = Need to request permission from user.
Usage
First you need to get an instance of FsFileSystem. You can:
Call fsOpenRead() or fsOpenReadWrite() to show a directory picker,
Call fsOpenReadFrom or fsOpenReadWriteFrom() and pass in a DataTransferItem from a drag-and-drop interface.
NOTE: fsOpenReadWrite does not guarantee the implementation supports writing. You should check
with capabilities afterward.
This is an example drop zone implementation in TypeScript
High level browser to file system integration library.
This library integrates the
File
,FileEntry
andFileSystemAccess
API to provide different levels of integration with file system in web apps.Basically, user can select a directory as a mount point, and browser can access read and sometimes write in the directory.
Support
Use
fsGetSupportStatus()
to inspect which implementation will be used.implementation
can be 3 values:FileSystemAccess
: This is used for Google Chrome and Edge, and possibly other browsers, under secure context.FileEntry
: This is used for Firefox when the FS is mounted through a drag-and-drop interface.File
: This is used for Firefox when the FS is mounted by a directory picker dialogThe implementation is also chosen in this order and the first supported one is selected. If you are on Chrome/Edge and
FileSystemAccess
is not used, you can useisSecureContext
to narrow down the reason.If you are wondering why Safari is not mentioned, it's because Apple made it so I have to buy a Mac to test, which I didn't.
After you get an instance of
FsFileSystem
, you can usecapabilities
to inspect what is and is not supported.See
FsCapabilities
for more info. This is the support matrix:write
?live
?FileSystemAccess
FileEntry
File
*
= Need to request permission from user.Usage
First you need to get an instance of
FsFileSystem
. You can:fsOpenRead()
orfsOpenReadWrite()
to show a directory picker,fsOpenReadFrom
orfsOpenReadWriteFrom()
and pass in aDataTransferItem
from a drag-and-drop interface.NOTE:
fsOpenReadWrite
does not guarantee the implementation supports writing. You should check withcapabilities
afterward.This is an example drop zone implementation in TypeScript
Retry open
You can pass in a retry handler and return true to retry, when opening fails. The handler is async so you can ask user.