-
Notifications
You must be signed in to change notification settings - Fork 162
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
Add a means to associate a PWA with a file extension #626
Comments
cc/ @PaulKinlan |
Some more thoughts on how this could work: have a manifest field similar to the following {
"file_extension_associations": {
"abc": {
"name": "My document format",
"url": "path/to/open/abc",
"icon": "/abc.png"
},
"def": {
"name": "My other document format",
"url": "path/to/open/def",
"icon": "/def.png"
}
}
} Notes:
Another question is when should the user be asked if they want to set up a file extension association? Here are some ideas:
Basically any use of a local file with a file extension in the manifest is probably the ideal time to prompt the user to set up file extensions, since it is a strong indicator this would be useful to them if they're already using those kinds of files. That helps make it discoverable and prompt at the most useful time. But I think there ought to be another way to opt-in without having to do that, e.g. requesting a permission in a user gesture. To prevent abuse, the browser could automatically decline if there is not enough engagement (or in cross-origin iframe, etc). |
Thanks! We also need to figure out how each OS allows for file extension registration and de-registration, specially if it can be done dynamically... this also needs to work with mime types via things like web share, etc. |
I am not sure this should necessarily be a part of this spec, though the work might extend it. Comments @PaulKinlan ? |
I didn't see this last year. This is something we're very interested in at Google. @ewilligers Some background: I worked on a very detailed (but now fairly obsolete) proposal for this in 2015: (This eventually evolved into Web Share/Web Share Target.) My current (vague) thinking on this is that we could use some variant of the (also obsolete) Writable Files proposal, and receive Writable File objects through Web Share Target. |
If you want to be able to just read a file that was opened, Web Share Target could be extended to receive Blobs and that's about it. But if you want to write back to the user's file system (and I do), then writable file objects are necessary. |
Would this be able to cover accessing entire folders too? Our PWA deals with very large user projects which are sometimes more efficient to save as a folder, so individual files can be updated, rather than needing to regenerate a single huge file every save. We had to release a download using NW.js to access these features via node APIs. It would be great if we didn't need to make a desktop download. |
@AshleyScirra I'd like to get to a place where the user can grant access to an entire folder, so you can build web apps that work at the folder level (like git). This is a very powerful permission though so we'd need to carefully weigh it up. We did something like this in the proprietary Chrome Apps fileSystem API. |
We actually were in that place with https://www.w3.org/TR/file-system-api/ before. My company used it in a popular app for video downloads/storage in Chrome for years. In fact, we would would still need that, and it was a bit of a shame that nobody else implemented it. |
If I'm not mistaken, the FileSystem API was only providing sandboxed storage (i.e., although it presents a file-like view, it only presented the web app with a virtual file system, not allowing the app to mount a real directory from the host system, and thus was isomorphic to LocalStorage or some other API for persistent isolated storage of large amounts of data). What I think we are talking about here (what chrome.fileSystem was) is an API to ask the user to nominate (through UI) a folder on their system, and provide persistent access to that non-sandboxed directory. Either way, this is out of scope for this particular manifest issue, which is about file associations. But it is something we're interested in. |
Yes, but that actually covers a lot of use cases, like for example @AshleyScirra's and ours.
There are some important differences between that API and e.g. localStorage/IndexedDB. For example it is not possible to get a filesystem URI for stored objects with the latter, meaning you cannot e.g. play audio or video directly from those.
True. Just wanted to register interest as well. :) |
I think it's worth pointing out that Microsoft now support PWAs in the Windows Store, with full access to the WinRT APIs. Their approach appears to be reasonably secure and it solves all the problems we have, since the additional API surface exposes everything else we need for our desktop app to be able to do everything we want. A Windows Store app can declare file extension associations in its (equivalent to a) manifest. Upon installing the app, if nothing else claims to use those file extension associations, it automatically applies them. (I think if other apps claim to support them, it adds it to an "Open with" list.) Additional features allow access to the file system, with an interesting permission model that is worth highlighting:
In other words file system access allows the minimum access possible after a user explicitly selects parts of the file system from UI, with the optional ability to remember this. Hosted web apps in the Windows Store can already do this, and it seems to have passed Microsoft's security review, so it might be a model to consider for the wider web. On the other hand Microsoft may be relying to some extent on their ability to review and remove misbehaving apps from the store, which doesn't apply to the web. |
Thanks for the info! Moving this discussion to WICG/file-system-access#14 --- not sure if writable-files is the right place to host this but I want to keep this issue focused on file associations. |
Any progress/updates here? This is also something I would find pretty helpful. |
@LukeWoodG We're (slowly) working towards this on a separate proposal site: https://github.com/WICG/file-handling |
Cool, maybe I'll look into contributing a bit :) Thanks for the update! |
This is now possible using the As of Chrome version 99 this feature is hidden behind a flag, to use it launch Chrome with the command line flag Here's a demo with source code. |
Let's keep this issue open until #1005 closes it. |
Closing a #1005 closed. And yes, using the file_handlers member in a web app manifest handles this... and I think file handlers is in the incubation spec. |
It's common on every OS to associate file extensions with some application (e.g., .psd opens in PhotoShop).
It would be great to figure out how we can associate files on a user's device to open with an installed web application.
The text was updated successfully, but these errors were encountered: