Skip to content

Read an existing file on the filesystem without copying #226

Closed Answered by rhashimoto
gmaclennan asked this question in Q&A
Discussion options

You must be logged in to vote

The alternative is to streaming copy a File object into OPFS, and then use an OPFS VFS to read the copied file, although I'm not entirely sure which one to use.

This will work. You could use any OPFS VFS with filesystem transparency (see feature table). The drawback is the time to copy a big file.

If you want to access the user's file directly (without copying to OPFS), you'll need to write a custom VFS. I'm unsure whether you can get a FileSystemSyncAccessHandle on a picked file (i.e. outside OPFS) if you're not on a Chromium browser; my guess is that Firefox and Safari don't support it. Also note that FileSystemWritableFileStream isn't supported on Safari and Android Chrome.

If you on…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by gmaclennan
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants