Edit CouchDB Attachments Directly with CouchDB-FUSE

After some hacking about with the rather badly documented Python FUSE bindings, I have finally managed to mount a CouchDB document's attachments directly onto a virtual filesystem!

Screen Shot of an attachment.

Use Cases

  • If you've read My Couch or Yours? Shareable Apps Are The Future by jchris, this is a great time-saver if you want to edit HTML, JavaScript, CSS or even image files directly using your favourite editor.
  • Uploading large numbers of files repetitively through Futon or even via a Python prompt becomes tedious very quickly: drag'n'drop or cp * is the way forward!

Installation

You need the following:

  1. Python FUSE bindings
  2. CouchDB-Python 0.5 or greater
  3. CouchDB-FUSE

Running python setup.py install should install a couchmount script on your path.

Usage

$ mkdir mnt
$ couchmount http://localhost:5984/jasondavies/_design%2Flinks mnt/
$ ls mnt/
$ touch mnt/foo
$ ls mnt/
foo
$ 

...you get the idea...

Happy Couching!

Update: Paul Davis has a nice alternative for automatically synchronising files if you're using couchapp:

inotifywait -m -r --exclude ".swp$" -e modify . | xargs -n 1 -I {} echo "couchapp push . wbm-targets" | bash