Hacker News new | ask | show | jobs
by ossobuco 658 days ago
It's already there: https://developer.mozilla.org/en-US/docs/Web/API/File_System...
2 comments

Why do APIs like this even exist? There's no legitimate reason for an HTML webpage to need this, it's just creating more attack surface for bad actors.
The File System API is a JavaScript API, not an HTML one, so it helps to think about it from that light (programs, not documents). The API allows tools such as photo editors, file converters, code editors, and the like to be given access to a set of files they can work on directly rather than needing to import and export from the browser on every change. If the attack surface is too much for a use case it can be globally denied by default in every major browser so you won't even get prompted.
JavaScript is just a feature accessory for HTML. There's no meaningful difference.
For whatever your preference in slicing that up is you can carry the "programs, not documents" reasons along.
Right, but programs are programs. Browsers are for webpages. If we want a program we run an .exe
The page needs permission. That permission step is similar to the act of downloading a native app. Except for the fact that the broswer gives even less access to your system than a native app so it's safer than a native app. (at least on desktop) That file system API is super useful for cloud based IDEs as just one example
Microsoft has an elaborate VS Code demo app that uses this API. Click "Open Folder" to see the API in action): https://vscode.dev
They say "like" this one because it only provides file level interaction, not disk level interaction.