Open file with system application in a Progressive Web App

最后都变了- 提交于 2019-12-05 05:29:18

Since this question has gained a lot of attention lately, for anyone interested on the subject there are very exiting news: the Writable Files API.

At this time the proposed new APIs are merely in the design phase, and there is a vivid discussion about the opportunity itself of introducing them. So it looks like we are still far from a production ready solution.

UPDATE 2019-04-12

There is now an explainer (also linked in the above mentioned post) with a lot of useful info on how the proposed APIs will/should work.

No, PWA cant listen to regular file system changes except for the files that are sandboxed to the app itself(which is like a virtual file system for each PWA installed)

You can refer to the only event listener for storage change here, which will be only for what you store from PWA to your PWA specific store space, which your external apps cant access.

<input type="file"> is the only way you can access regular storage file system, which will not have any even listener.

What you are expecting is something many developers are hoping to get soon, but not in the general PWA spec form. Its mainly blocked by security constraint as you have mentioned. Think of all PWA websites(which looks like a normal web to end users) we visit in web browser have access to your full file system.. who will accept and like that fact? No one. PWA should evolve to have separate permissions once its added to home screen and we can expect to see these features after that.

Update: Only alternate solution you have to use both filesystem and PWA is to wrap your PWA in a Cordova and use native file system API along with PWA features like Service workers to have offline capability. If your targeted users webview is recent enough(v40+), it will support service workers. With this option, can't distribute the apps via "Add to home screen" option though and if you do, it wont support file system access.

Using Electron to wrap your web app can be another alternate, which will also give access to your file system. IDEs like Atom, VS Code are built using Electron and HTML/CSS/JS.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!