Monday, December 20, 2010

CouchDB, cURL and Images

Storing images in CouchDB is quite a common requirement these days. CURL is a nifty little tool to play around with HTTP, so I quickly fired up console, executed a few command lines to quickly upload an image to my CouchDB instance.

CURL gives me the details of the HTTP conversation, probably this will help me quickly create client apps which does similar things in any language.

If you have your CouchDB instance running in your localhost and you have already created a database (Say album). The CURL command line will be something like this.


curl -vX PUT http://localhost:5984/album/1/attachment -H "Content-Type: image/jpeg" --data-binary @/path/to/my_picture.jpg


And VOILA !!!

http://localhost:5984/album/1/attachment