Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web API as virtual filesystem?

Tags:

fuse

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!

like image 421
AnC Avatar asked Aug 06 '10 08:08

AnC


People also ask

Can I use file and directory entries API?

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.

What is native file system API?

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.

Can we access file system from browser?

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.

Can a web app access local files?

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.


1 Answers

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.

like image 124
slebetman Avatar answered Nov 29 '22 11:11

slebetman