Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Use Case : store FileSystemDirectoryHandle or FileSystemHandle in Redux Store #368

Open
VittorioAccomazzi opened this issue Apr 15, 2022 · 5 comments

Comments

@VittorioAccomazzi
Copy link

VittorioAccomazzi commented Apr 15, 2022

I'm using using the File System Access API with an application build with React and Redux. I need to store FileSystemDirectoryHandle and FileSystemHandle objects in the redux store, which requires to be serializable.

I see from the specification that these classes are serializable, it appears to me that they are serialized only by the API for IndexedDB, or postMessage, as stated in this article.

So I'm wondering if I can serialize the manually, and so use them with a Redux application.

@slaymaker1907
Copy link

I had a related proposal at #295. My use case is that I’d like to store the handle in the file itself for self modifying HTML files.

@danqdinh
Copy link

danqdinh commented Feb 15, 2023

objects in the redux store
@VittorioAccomazzi
i guess you should use indexeddb to store binary handle for now

@a-sully
Copy link
Collaborator

a-sully commented Jun 21, 2023

whatwg/fs#46 proposes a new method that returns a unique string serialization of a FileSystemHandle, though note that this is a one-way serialization (i.e. handle -> string, but not string -> handle) that is subject to change if site data is cleared.

This string can be used as a key to store a string:FileSystemHandle key:value pair in IndexedDB. So the FileSystemHandle itself can't be directly stored in a redux store, but this string could be stored in a redux store as a pointer of sorts

@jimmywarting
Copy link

but not string -> handle) that is subject to change

Hypothetical, if it where possible to create a handle from a string, would it then be accessible to postMessage it to a other origin if i gave them the string or would the handle still only be accessible to the domain who called getUniqueId() such in a way that it was salted with the origins domain name? like sha(checksum + origin)

fyi, i have wanted to be able to send a handle with postMessage to another origin for quite some time now...

@a-sully
Copy link
Collaborator

a-sully commented Jun 21, 2023

Hypothetical, if it where possible to create a handle from a string, would it then be accessible to postMessage it to a other origin if i gave them the string or would the handle still only be accessible to the domain who called getUniqueId() such in a way that it was salted with the origins domain name? like sha(checksum + origin)

The latter. See https://github.com/whatwg/fs/blob/9063e176651af48aa8ad8f0a6537e710d477def2/UniqueID.md#expose-the-same-id-to-all-sites

fyi, i have wanted to be able to send a handle with postMessage to another origin for quite some time now...

This would likely be in the context of something like #245, at least at first. Not something we're planning to work on anytime soon, though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants