Storage Access Framework (and Accessing External Storage)

The current folder picker is less-than-ideal, in my opinion. Especially considering Android provides a cleaner interface that achieves the same results.

Is there also a reason that 6.0 devices still can’t sync external storage devices? Is there any way around that limitation currently? I know for a fact that other apps can access external storage fine, they just need to use the Storage Access Framework (although logically I would have thought the new runtime permission for Storage Access would have achieved the same thing, but maybe that’s an Android quirk I’m not aware of).

(My usecase is an Android TV with an external HDD plugged into one of its USB ports, I want Syncthing to sync to that external HDD - is this possible currently?)

Syncthing is implemented in golang, there is no storage access framework in golang.

Golang issue

Ah, man. That’s a real bummer, and unfortunately a deal-breaker for me. :frowning:

Feel free to contribute a storage framework implementation to golang to rectify this.

I read somewhere that Marshmallow can create some sort of united filesystem with an sdcard. I reckon one should be able to circumnavigate the golang limitation using that feature, but not without caveats.

My recently bought Android phone doesn’t have Marshmallow yet, but I was considering going down that route for exactly that reason.

Marshmallow can format the SD Card with ext4 (I think) and encrypt it (as all storage will be with Marshmallow) so it can only be used inside that phone. Then, the SD Card can be used/accessed like the internal memory.

But this will not be possible (as far as I know) with USB storage. I just tested this with my Nexus 5. Android just offers me to format a USB Stick for “external storage” which will not be writable without the Access Framework.

I have a vague idea what could be an interesting (but I expect too extensive) addition to Syncthing, which could help here: virtual file system providers, i.e. an API where we can provide filenames and file-content via either a call to a script or via a TCP socket.

Something similar to the plug-able VFS implementations for SQlite, but on a more abstract layer, e.g. TCP.

If I understand you correctly, that’s basically what document provides do. Did you read the page about them?

Ah cool, no, did not read that. Basically I was thinking about the other way around, i.e. simulating a filesystem for Syncthing to use (where the real data could be on the FS, in a DB, etc., without the Syncthing core knowing about it).

In SQLite you basically provide an implementation of open(), read(), write(), etc. sys-calls to the engine, where you are free to store and retrieve the data however your implementation sees fit.

Or maybe I just read the Syncthing ticket the wrong way around?

Ah I should clarify this. The storage access framework allows access to various storage providers. One of those providers is the sd card. And the only way to access the sd card from an app on Android 4.4+ is through the storage access framework.

Another feature is that you can define your own storage provider, which lets other apps access files. This provider does not need any local data, it can be backed by a cloud for example (Google Drive implements this).