I am currently playing with couchdb and testing out the 'standalone attachments' feature, which is described near the bottom of this page.
I am trying to use curl's --data-urlencode feature to send the creation request, which only half works. I can create the attachment and retrieve it, but the Content-Type field is wrong, so the image won't display correctly.
To be more accurate CouchDB seems to work by returning the attachment using the same Content-Type it was posted in. (which is perfectly sensible IMO) My problem is curl doesn't send the correct code. Here's the details;
curl -vX PUT http://localhost:5984/dafttest/666/attachment --data-urlencode image/jpeg@xi_on_beach.jpg
* About to connect() to localhost port 5984 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 5984 (#0)
> PUT /dafttest/666/attachment HTTP/1.1
> User-Agent: curl/7.19.4 (x86_64-pc-linux-gnu) libcurl/7.19.4 OpenSSL/0.9.8k zlib/1.2.3
> Host: localhost:5984
> Accept: */*
> Content-Length: 495389
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
So the short version of this question is; how to I get cURL to send the correct Content-Type ?
EDIT:
I release that my other mistake was to use --data-urlencode, when to get it to work I need to use --data binary @filename together with the -H option that Dale suggested.