incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark J. Reed" <markjr...@gmail.com>
Subject Re: upload file via curl
Date Fri, 17 Sep 2010 15:43:41 GMT
On Fri, Sep 17, 2010 at 10:13 AM, slymak <slymak@gmail.com> wrote:
> how to include attachment into cURL?

Once you've created $database/$document, just PUT the contents of the
file you want to attach to
/$database/$document/$attachmentName?rev=$rev, where $rev is the
revision from your newly-created document.  Example:

curl -X DELETE http://localhost:5984/test
curl -X PUT http://localhost:5984/test
(cd jcl
for file in *; do
    rev="$(curl -X PUT http://localhost:5984/test/$file -d '{"name":
"'"$file"'", "date": "'"$IDATE"'" }' | sed -ne
's/^.*"rev":"\([^"]*\)".*$/\1/p')"
    curl --data-binary @"$file"  -X PUT
http://localhost:5984/test/$file/contents?rev="$rev"
done)
-- 
Mark J. Reed <markjreed@gmail.com>

Mime
View raw message