10 ms·
Web Writable Files API: Simplifying Local File Access
- slartibardfast0 8y agoThis looks great! I hope a capability driven multi-monitor api gets some attention in the near future too!
- 1234567try 8y agogreat!
- carlosdp 8y agoThis is a great idea. One interesting consideration would be how it would handle symlinks. Would it follow them? Could that be used as an attack vector to exit the user-specified directory?
- 1234567try 8y agoGreat!!!
- deleted 8y ago[deleted]
- kevin_b_er 8y agoWhile I'm concerned the security implications greatly, one should not always assume network access always works or that it is effective at all times. In the United States, for example, bandwidth limitations and caps are rampant far and above what is needed just to saite the greed of our corporations. Given the current political control of the judiciary and executive branches, I don't expect this to change any time soon. We'll likely see more and more limits to our ability to do "cloud" things unless we offer a greater profit than ever before to the incumbent ISPs. Being able to do something offline is important. I can see how this goes forward with Google goal to get their "chrome is an OS" model.
- binarynate 8y agoI agree that offline access is important. Fortunately, the Service Worker browser APIs now allow enable web apps to work offline, too: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API https://developer.mozilla.org/en-US/docs/Web/API/Service_Wor...
- asaph 8y ago> The primary entry point for this API is a file picker, which ensures that the user is always in full control over what files and directories a website has access to. Every access to a user selected file (either reading or writing) is done through an asynchronous API, allowing the browser to potentially include additional prompting and/or permission checks. I'm glad they are taking a security-focused approach from the beginning of the design phase. I expect no less from Google. However, I worry that the approach of putting the end user in charge of approving/denying access to resources puts an unreasonably high burden on users. Many people simply click to dismiss dialogs without even reading them, let alone thinking carefully about what they are agreeing to. This is asking for trouble. I would rather see a sandbox approach that restricts the locations and types of files that can be read and written.
- jcoffland 8y ago> I would rather see a sandbox approach that restricts the locations and types of files that can be read and written. Which is exactly what is in the security proposal linked at the bottom of the article.
- asaph 8y agoThanks for pointing that out. I missed these 2 items on first glance. Limiting access to certain directories: https://github.com/WICG/writable-files/blob/master/EXPLAINER.md#limiting-access-to-certain-directories https://github.com/WICG/writable-files/blob/master/EXPLAINER... Limiting write access to certain file types: https://github.com/WICG/writable-files/blob/master/EXPLAINER.md#limiting-write-access-to-certain-file-types https://github.com/WICG/writable-files/blob/master/EXPLAINER... FWIW: On the surface, this appears to contradict the following quote from tfa: > ...ensures that the user is always in full control over what files and directories a website has access to. A sandbox is not full control.
- ghayes 8y agoIf the user can control the sandbox, say by a runtime setting or preference, then the user still is in control, but default safe.
- andrewstuart 8y agoThis is a great idea and will mean that many Electron applications can just run much more securely as plain web applications.
- devwastaken 8y agoRelying upon browser features for native access will be trouble. Google could revoke the feature from chromium at any time. And in any real application you will need to interact with plenty of folders users cannot be expected to know, like Appdata.
- Klathmon 8y agoBy that line of thinking relying on OS APIs will be trouble as Microsoft or Apple could remove features at any time.
- devwastaken 8y agoIf they are shiny new features, absolutely. Browser features, especially from Google, are notorious in being experimental and removed when they want to be. Browsers in general will remove things unless their internal teams find use for them. Browsers do not want to support more features than they have to, as can be seen by subscribing and listening in on the mailing lists for Firefox. However your equivalence in this case is a completely false one, because file system API's are not going to just be 'removed' as that would break literally every application that uses standard fopen. over 20 years of standard is a pretty good boat to stand on unless there's signals that say otherwise.
- Klathmon 8y agoWell sure you shouldn't rely on anything new for core aspects of your application without a plan for what happens if they go away. Especially when the API in question isn't even implemented yet... But that's not how I understood your comment above, which was to not rely on any browser features for native access, which IMO isn't good advice. Sure, you shouldn't go out and build a business around the "Web Writable Files API" tomorrow, but if it gets standardized, and if it gets implemented in a few major browser engines (which is a requirement for standardization in this context), then yeah go ahead and start to rely on it more. But this has very little to do with these new proposed APIs, and more with general software development.
- euroclydon 8y agoIf you could write an executable file, you could make a compiler in browser JS.
- tantalor 8y agoWell, you can already do that, but the file has to be written to your Downloads folder or wherever.
- pjmlp 8y agoYou already can do that by compiling into a WASM module and reloading it afterwards.
- deleted 8y ago[deleted]
- icebraining 8y agohttps://bellard.org/jslinux/index.html https://bellard.org/jslinux/index.html, besides the whole kernel, actually includes a functional port of gcc! You can compile C files right in the browser, and then use "export_file [file]" to get it to your machine.
- jcoffland 8y agoThis could be a great way to allow Web apps to talk to native apps. At Folding@home our client software uses a Web frontend. This frontend talks to the native Folding@home app at localhost over a socket. The problem is that browsers are starting to show security warnings for any non-https traffic and it's not possible to securely give the native app a valid SSL certificate. Reading and writing shared files would let the frontend talk to the back end more securely. Allowing the Web app access to a directory, with disk space restrictions, would be ideal.
- yjftsjthsd-h 8y agoIsn't localhost exempt from http/s restrictions?
- 0xCMP 8y agoIt's a special case, but HTTPS specific features don't always work. In this cause it's an HTTPS website talking to a local HTTP service which causes the cross-site errors.
- bmm6o 8y agoYou can't get a certificate for localhost, but you can get one for foldinglocalhost.com and resolve that to 127.0.0.1.
- unilynx 8y agoThat requires you to also ship the private key to end users, and your certificate will be revoked once the CA discovers it
- euroclydon 8y agoNo, you can just install a self-signed unique cert for each machine.
- aaaaaaaaaab 8y ago
- joshfraser 8y agoOne of the great things about browsers is the way you can trust them to be reasonably sandboxed from the rest of your machine. Features like this chip away at that trust model and open up new attack vectors against unsuspecting users. I get the usability benefits, but the security implications are scary. How easy would it be to trick my mother into uploading her profile picture and have the site change that file into a malicious executable without her realizing? At a minimum, I'd hope you would be restricted from changing file permissions or editing any executables.
- nine_k 8y agoAs you surely noticed, for last 10 years the browser is actively trying to replace your desktop OS, so that the browser would become the platform, instead of Windows / macOS / Linux / anything else. Imagine the desktop becoming ChromeOS on any computer, not just Chromebooks. For this, the browser must make all the traditional OS interfaces available. It has interfaces for accelerated 2D and 3D graphics, audio, USB, process management (workers), networking (including peer-to-peer), and a number of persistence mechanisms. But before it takes over completely, it has to interoperate with the host OS a bit, too, by exposing the filesystem. (A decade more, and maybe the vision of Inferno [1] will sort of kind of be implemented.) [1]: https://en.wikipedia.org/wiki/Inferno_(operating_system) https://en.wikipedia.org/wiki/Inferno_(operating_system)
- Individualist 8y agoI would argue that you could use a combination of local storage and global state in these web apps to approximate a file system already. Not to mention lazy loading and web workers to cache larger files needed to run a web app. As well as parrelism and currency already offered by web workers.
- nine_k 8y agoApproximation is not what it's about. It's about integration. Write that google doc and store it as a local .docx or .odc. Edit that 20 MB raw picture in a browser app and store it back to the disk, instantly, then feed it to a traditional desktop editor. Write that Python script in a Web IDE, store locally, and upload it to an Arduino.
- eastendguy 8y agoIs this API needed? I understand the benefits, but web apps or Chrome extensions that _really_ need file access can already use the Native Messaging API and ask the user to install a native app, like here: https://a9t9.com/kantu/x#fileaccess https://a9t9.com/kantu/x#fileaccess The advantage of an explicit app installation is that users/companies that want to avoid such file access (and the many other things that native apps can do) can simply avoid/block app installations. In the last two decades users have learned that "as long as it's inside the web browser, it's safe". If web apps themselves become too powerful this security approach breaks down.
- devwastaken 8y agoafaik native messaging requires platform dependent things such as registry entries on windows.
- kevingadd 8y agoThe native messaging api is buggy and limited and requires lots of platform specific code. It's not a good solution for any problem.
- Wowfunhappy 8y agoI don't know that native apps are the best resolution, but I absolutely agree with the last paragraph. There needs to be really clear user messaging around this type of access. The current state is, IMO, insufficient.
- Ajedi32 8y agoA native app would have full filesystem access. This API only grants access to files/directories you open in the web app.
- zawerf 8y agoThis will be amazing for simple webapps! In a lot of use cases, all you really want is a simple way to read and save a small blob of data. But to achieve this today you would have to do one of: - Save it in local storage, but lose their data if they clear it or use another device. - Build out a REST API backend, but need to also build auth and account management. - Use a backend as service such as firebase, but still costing you to store the data. - Use a filepicker api to save to the user's cloud storage. For example Google Drive has a file picker: https://developers.google.com/picker/ https://developers.google.com/picker/. But not everyone use the same cloud drive (icloud, dropbox, onedrive, etc). With local file access, it's more or less the same as the filepicker api solution except they are free to save it to a non-syncing file location too if they choose.
- EGreg 8y agoWhy not IndexedDB? Is that cleared also when you reinstall an app or something
- zawerf 8y agoYea it has the same problems as web storage. Also it's too opaque so the typical user won't understand that clearing their browser data means losing their work. They have already been trained by other sites to believe that their data should be persisted to the site's servers and that they should see their data even if they open the site on a different device. Forcing them to choose where to save the data should hopefully clear up where their data lives. If they need multidevice they can sync their filesystem folders with one of many third party cloud storage of their choosing (such as dropbox). I think it's a perfect fit for webapps like as photopea.com (photoshop clone in the browser) that came up on HN the other day.
- RandomBookmarks 8y ago"The primary entry point for this API is a file picker (i.e. a chooser)." ...so what would be difference to today, where a user can "upload" files to the browser's local storage, and then the web app can work with the file(s)? I get it that you avoid to have to "re-download" the file, but that seems to be a small benefit for the risks we get.
- euroclydon 8y agoThe browser retains the permission for the app to write the file back later, I believe.
- Paul-ish 8y agoHopefully the file picker API looks very different from the file upload API to cue the user that something different is happening.
- timwis 8y agoParticularly interesting in light of linux's "everything is a file" principle...sockets, printers..
- pjmlp 8y agoActually that is an UNIX thing, and not everything is a file on UNIX. On Plan 9 and Inferno everything is indeed a file.
- tinyvm 8y agoA couple months ago I started studying PWA. I realized PWA's potential was on Desktop and not really on mobile. I came to realize that PWA missed really two things to change Desktop for good : - Sandboxed FileSystem API - Standard Operating System Support Most apps like Slack, Discord or Twitch can barely justify their usage of Electron... beside the possibility to have those apps in a separate OS Window they don't make an extensive usage of Node.JS like VSCode which spawn "child_process". They just seat there , in a separate OS Window and they can launch at OS startup too..but in order to have those two features you must completely give up on security and give access to almost everything on your computer... PWA really bring a new dimension to Desktop App, if Windows and MacOS brought native support to PWA ( using Edge and Safari without the need for Chrome ) this would change the industry for ever.
- nicoburns 8y agoAgree that PWAs have a lot of potential on Desktop. But they're also really good on mobile. Both Facebook and Tinder have PWAs that I prefer to their native apps...
- devwastaken 8y agoProblem with PWA: Native access, Browser versioning and seperation of processes. 1. If when you ran a .net application all .net applications shared the same parent process that'd be a significant problem. 2. Many electron clients control their versions because there are bugs, quirks, removal of features, or other changes in chromium versions. Discord last time I checked is still on 56. 3. PWA's do not have native access. Discord requires that to spawn IPC communications with game overalys, which are another native process. PWA's are meant more for mobile, but even there you are of course, limited. Firefox and Safari would change the world if they actually cared about doing that. They're about market share, not about the technology anymore. Firefox was in a position of making it possible to simply ship the firefox binary, and you could add your js and css changes, effectively having the full firefox browser as your 'app'. Which means it could be triggered to auto-update like normal firefox, but still have your UI and act as a browser. Firefox abandoned that route and instead is focusing upon whatever Chrome impliments, like Custom Components. Safari also doesn't care about anything but linux and mac.
- burtonator 8y agoI just finished banging out a new Electron app (https://getpolarized.io/ https://getpolarized.io/) It's an offline-first app for managing and annotating PDF and web documents. The idea was that with Electron I can have direct access to the filesystem and be fully integrated into the browser as well. For the most part it works. The users can easily browse the local filesystem and also access some operating specific features. But let me tell you -it's rather schizophrenic to use something like Electron. It just doesn't know whether it's a browser or a web server and then there's the issue of dealing with process communication within Electron. Chrome is its own process and node the main process and you have to communicate via message passing - not super fun. Now we have PWAs and they're far from idea but it might be that an API like this, along with PWAs, and maybe a bit more functionality could replace Electron for building these types of hybrid apps.
- nusq 8y agoHas a huge fan of the tiddlywiki project this is a welcome feature .
- dreamcompiler 8y agoI hope this can be made to work securely. The main thing holding back web-based IDEs is file system access. It wouldn't be horribly difficult to port e.g. Emacs to Javascript (or more likely WebAssembly) if file access was available. I know this sounds ridiculous, but it would be doable.
- z3t4 8y agoI like the idea of a File API, to make it easier to for example search files. But I'm afraid we'll end up with the same problem as native apps, where apps would ask for all permissions, even if they don't really need them.
- EGreg 8y agoI’m wondering how useful it is to save files on the local filesystem in 2018. I can understand syncing Google Drive and saving stuff there. Or Resilio Sync or any number of other solutions such as Dat. You Already have filepickers to open and read files. And you can save files as I indicated - via syncing to a service, where you have control of what goes where and it’s still there if you lose the device. And it can be encrypted where the local devices have keys for syncing. The only new use case I can think of that this enables is overwriting existing files - which is dangerous!
- icebraining 8y agoEven in 2018, not everyone is online all the time, or has a connection capable of uploading large files (due to speed or caps). And frankly, it's just wasteful to upload everything.
- nicoburns 8y agoDepends how heavily you rely on the cloud. I certainly don't have everything there (and don't want everything there!). Plus, going via gdrive is slow compared to say saving the file directly from the browser, and then opening it on a native app instantly.
- deleted 8y ago[deleted]
- exabrial 8y agoWhy are we reinventing 100% of the problems from Java and flash?
- wild_preference 8y agoSafari 11 or 12 introduced a new extension system where Safari extensions ship as a macOS app with a Safari extension component that can communicate with the native app. And the macOS app has standard Mac Store sandboxing options (by default, no FS access outside of its bundle). I've written some extensions for personal use and so far it's been a great trade-off.