Method | PUT /db/doc/attachment | |
Request | Raw document data | |
Response | JSON document status | |
Admin Privileges Required | no | |
Query Arguments | Argument | rev |
Description | Current document revision | |
Optional | no | |
Type | string | |
HTTP Headers | Header | Content-Length |
Description | Length (bytes) of the attachment being uploaded | |
Optional | no | |
Header | Content-Type | |
Description | MIME type for the uploaded attachment | |
Optional | no | |
Header | If-Match | |
Description | Current revision of the document for validation | |
Optional | yes | |
Return Codes | ||
201 | Attachment has been accepted |
Upload the supplied content as an attachment to the specified
document (doc
). The
attachment
name provided must be a URL encoded
string. You must also supply either the rev
query argument or the If-Match
HTTP header for
validation, and the HTTP headers (to set the attacment content
type). The content type is used when the attachment is requested
as the corresponding content-type in the returned document header.
For example, you could upload a simple text document using the following request:
PUT http://couchdb:5984/recipes/FishStew/basic?rev=8-a94cb7e50ded1e06f943be5bfbddf8ca Content-Length: 10 Content-Type: text/plain Roast it
Or by using the If-Match
HTTP header:
PUT http://couchdb:5984/recipes/FishStew/basic If-Match: 8-a94cb7e50ded1e06f943be5bfbddf8ca Content-Length: 10 Content-Type: text/plain Roast it
The returned JSON contains the new document information:
{ "id" : "FishStew", "ok" : true, "rev" : "9-247bb19a41bfd9bfdaf5ee6e2e05be74" }
Uploading an attachment updates the corresponding document revision. Revisions are tracked for the parent document, not individual attachments.