Hacker News new | ask | show | jobs
by mg 80 days ago
> but trying to save data required hosting it somewhere

With the File System Access API, webpages nowadays can read and write local files just like desktop applications:

https://developer.chrome.com/docs/capabilities/web-apis/file...

Try this text editor for example:

https://googlechromelabs.github.io/text-editor/

It works nicely on Desktop and Mobile.

4 comments

*In Chrome.
That file editor seems to work in Firefox. I just tested the save/open functionality.
It's not using the File System Access API, on Firefox it uses <input type="file"> for file-picking, and the save just downloads it. It's not synchronizing anything with your filesystem.
I see. Thanks for enlightening me.
Do you know the reason for that? The File System API does seem to be well supported on Firefox: https://developer.mozilla.org/en-US/docs/Web/API/File_System...
Firefox unfortunately does not support the File System Access API. You can try by calling the most fundamental function, the one that asks the user to select a file:

    window.showOpenFilePicker()
What Firefox supports is a "File System API" which creates something similar to the other old ways of storing data in a browser, like cookies and indexeddb. You cannot use it to edit normal files on your disk.

This is my main gripe with Firefox. They force their users to either store everything in the cloud or go through the arcane "download" workflow where you have to manually save files.

> Firefox unfortunately does not support the File System Access API.

I would not call it unfortunate. Browsers should not have access to the file system, USB ports, etc. Perhaps in "PWA"s, if the user has a way of giving and withdrawing consent.

Iirc the File System Access API should always originate File objects from an input picker so that the user selects the file to be opened and not give more access to apps than users allows?
It just downloaded the file on my firefox.
*In browsers that have implemented it
My dream is that you could write to Google Drive or iCloud Drive transparently too if the browser allows you to
I believe you are able to connect to a Google Drive account with a purely client side site via google oauth and then using the Google Drive rest api. There was an article in particular that I liked that walked through it. Let me see if I can find it
Yes but Google OAuth is a nightmare if you want to "publish" your client so that anyone can use it. If only you use it, you can add yourself as a test user. Just know your access token expires super fast and you will have to frequently re-auth. Its crazy annoying.
This is possible with RxDB, you can sync from browser to google drive or ms onedrive
it's not only about saving data but easily sharing too. I think the capsule file is great for sharing one's work without the hassle of hosting.
Ease of backup too. One of the issues I take with browsers allowing web apps to save data locally is that they don’t also expose a way to easily locate the data in the filesystem or export it, and to my knowledge on-disk format isn’t standardized and so portability between browsers is also a concern.

The effect of this is that unless the user uses migration assistants or similar when upgrading to a new computer is that they’ll lose all local web app data. To me to this feels like a serious problem but when it’s brought up it tends to be hand waved away.

Even better how about a fully functional VSCode: https://vscode.dev

The File System Access API makes it possible.