I've been toying with the idea of representing RESTful web APIs (e.g. CouchDB, Twitter) as a file system - just for fun and as a learning experience. However, I have no idea whether that's feasible or how to get started.
For example, a resource like http://example.org/foo/bar might be accessible via /mnt/example.org/foo/bar. I imagine ls /mnt/example.org/foo
would return bar baz
.
While I know of FUSE, I don't really know anything about it. Not being a low-level programmer, I wonder whether there's some sort of Python API, or perhaps I could simply write some Bash script to trigger curl
requests for file-system queries?
Any pointers would be greatly appreciated!
In Chrome, you can use the File and Directory Entries API with the Quota Management API, which lets you ask for more storage and manage your storage quota.
The File System Access API (formerly known as Native File System API and prior to that it was called Writeable Files API) enables developers to build powerful web apps that interact with files on the user's local device, such as IDEs, photo and video editors, text editors, and more.
Some browsers offer additional APIs to create and manage file systems, such as Chrome's requestFileSystem() method. This interface will not grant you access to the users filesystem. Instead you will have a "virtual drive" within the browser sandbox.
Web browsers (and JavaScript) can only access local files with user permission. To standardize the file access from the browser, the W3C published the HTML5 File API in 2014. It defines how to access and upload local files with file objects in web applications.
The standard for this is called WebDAV. See: http://webdav.org
There is even a FUSE driver for it: http://savannah.nongnu.org/projects/davfs2
Looking at the source code it appears that davfs2 is written in C. It could be a fun project re-implementing it in Python or Perl.
Ah, from the comments I see what you want are pointers on how to write a FUSE module. Sure, your idea of writing something like TwitterFS is feasible. It would probably work like the stuff in /proc.
The Perl library for implementing fuse is quite well documented: CPAN - Fuse. All you need is to load the module and implement the relevant callback functions. Looks easy enough.
Here's a Python FUSE library: fusepy. It's not as well documented but there are several examples given including a functional sftp filesystem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With