Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Getting Started with the File System Access API (css-tricks.com)
71 points by todsacerdoti on Feb 15, 2022 | hide | past | favorite | 31 comments


This is what apps like photoshop.adobe.com and vscode.dev use to let you edit local files - with a fallback of single file access with input/type="file".

I hope Firefox and Safari support this API soon. The alternative of installing native executables isn't any more secure.


from the caniuse data, it looks like Safari might actually be working on this?

Which is both hugely surprising and deeply concerning, given their track record with both implementing APIs and the stability/reliability of them.... The tinfoil hat me in says they might fuck it up to justify the apple ecosystem stance of app store or nothing.


Put down the tinfoil, the WebKit team has been on a tear recently and very actively hiring to keep that momentum and very actively seeking feedback. Regardless of Apple’s priorities, Safari is very much on an improvement track


I think a more justified and nuanced criticism is that Apple is harming the web by tying Safari updates to macOS and iOS updates, which makes the criticism of Safari being the new IE a lot more justified (now that IE has been replaced by the evergreen cross-platform Edge). Safari might get more frequent and broader updates but that's no use when people are still using older versions of macOS and iOS and might be stuck with it (especially with fresh memory of Apple intentionally slowing down iOS devices to encourage buying new hardware).


Safari on macOS is supported two major OSes releases back. The latest iOS is supported on iPhones launched in 2015 and later. How many users on older versions of Safari are limited by OS version?


To some extent this is a fair criticism, and I certainly wish Safari were less tied to OS releases. That said, iOS users tend to update about as quickly as you could hope for (and update hardware often enough that being left behind is uncommon), and macOS users who lag behind tend to use Chrome anyway.


Where Chrome is fast and loose with APIs, Safari and Mozilla actually stop and think before implementing them.


Can't macos use chrome for file-access-api instead if Safari does/will not support it?

Same issues with PWA support as far as I can tell, maybe Macos users just install chrome and use that too?


It's great and I'm using it for https://sqliteviewer.app.

It would be even better if it allowed partial reads/writes with offsets, but alas, security concerns seem to block that.

I'm looking at the File Handling API[1] next to let the (installed) web app open .sqlite lite files from the OS file explorer.

[1]: https://github.com/WICG/file-handling


> Getting Started with the File System Access API

> css-tricks.com

Here I thought CSS was getting just a bit more spooky. Thankfully not.


They regularly post JS stuff, it’s pretty much just FE Stuff Weekdaily.


Cool blackhat brief on how it can be abused: https://i.blackhat.com/USA21/Wednesday-Handouts/us-21-Intern...


I didn’t see any security features mentioned… am I the only one a wee bit terrified? Am I just paranoid?


I remember some time ago Firefox denied all the local access as a security issue - despite all the dialogs that asked for rights. Had to find some other ways to access simple txt file - via link.


Firefox never has implemented the filesystem access API: https://caniuse.com/native-filesystem-api


They didn't even want to give extensions that kind of capabilities (and in the process significantly crippled mass downloaders like DownThemAll and others), so yeah…


I was refering to ability to manipulate local files from Firefox, that existed 6 - maybe 8 years ago - long long time ago, when this filesystem API did not exist.


There's explicit dialogs the user has to opt into.


Most (>80%) of users are highly computer illiterate. Even among younger folks. There has recently been a story on hn about zoomers not "understanding" how file systems work.


Statistically they have a lesser understanding of hierarchical filesystems, because Apple and to a lesser degree Google have been going out of their way to hide that on mobile OSes for some reason that was never really clear to me. They still understand files though.

And at the end of the day there's only so much you can do. The same kind of people that will click yes on any dialog will also click yes on "do you want to run this exe you just downloaded", and that'll get you file system access just fine too.


Yeah hierarchical file systems are not the one true way to organize your data.

But from my understanding, the user grants access via this API on a directory based level when the website asks for access to one directory. If you have no concept of directories, or you put everything directly into one directory, it's tough to make this restriction useful. So in this instance, knowledge of hierarchical file systems is relevant, even if new operating systems make this knowledge increasingly obsolete.


> Yeah hierarchical file systems are not the one true way to organize your data.

It's the way nearly all computers, mobile or not, organize data. Some hide this fact to because they either think they know better than the user (Apple) or they want to make it really painful to not store all of your data in their backend (Google).

> But from my understanding, the user grants access via this API on a directory based level when the website asks for access to one directory. If you have no concept of directories, or you put everything directly into one directory, it's tough to make this restriction useful. So in this instance, knowledge of hierarchical file systems is relevant, even if new operating systems make this knowledge increasingly obsolete.

I think that illiteracy here has more to do with the advent of mobile OSes and people only exposed to mobile devices. Filesystem access isn't supported on mobile browsers at all so there isn't really a problem there (except for mobile Safari, which also doesn't expose folders to users, being on Apple's direct control).

https://caniuse.com/native-filesystem-api


If you’re concerned about users having literally no floor to their technical understanding or awareness, then those users are already vulnerable to websites with a form that says “type your Gmail address and password here.”


You mean like in Android ? Where you give an app access to all your files ?


This is amazing for indie note taking apps like https://bangle.io . I will no longer have to tell users to switch to chrome now.


Really organic plug you got there.


as much as I'd like to use this no browser really supports it aside from chrome. the brave team even specifically disabled it due to security issues.


Perhaps not coincidentally, today WebKit also blogged about availability of the API in Safari as well.

https://webkit.org/blog/12257/the-file-system-access-api-wit...


Note that, unlike Chrome, Safari only supports “origin private” files which means it cannot be used to access files already on your system (e.g. no vscode.dev, photoshop.adobe.com opening of local files).


The main selling point to me for the file system access api is the ability to write directly to the file system on the device but from what I could understand in that blog post is that the 'files' that you write to don't actually map to the device's fs itself. Has anyone used it to write to an existing directory or is it just an alternative and more familiar interface to indexedDB?


I have been using it to provide ability to read existing markdown notes in a users directory see [1]. So far it works great but browser support is limited to chrome and edge.

[1] https://bangle.io




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: