Search code examples
fuse

web API as virtual filesystem?


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!


Solution

  • 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.