You can include one or more attachments with a given document by
incorporating the attachment information within the JSON of the
document. This provides a simpler alternative to loading
documents with attachments than making a separate call (see
Section 6.8, “PUT /db/doc/attachment”).
Table 6.3. Document with Attachments
| Field | Description |
_id (optional) | Document ID |
_rev (optional) | Revision ID (when updating an existing document) |
_attachments (optional) | Document Attachment |
filename | Attachment information |
content_type | MIME Content type string |
data | File attachment content, Base64 encoded |
The filename will be the attachment name. For
example, when sending the JSON structure below:
{
"_id" : "FishStew",
"servings" : 4,
"subtitle" : "Delicious with fresh bread",
"title" : "Fish Stew"
"_attachments" : {
"styling.css" : {
"content-type" : "text/css",
"data" : "cCB7IGZvbnQtc2l6ZTogMTJwdDsgfQo=",
},
},
}
The attachment styling.css can be accessed
using /recipes/FishStew/styling.css. For more
information on attachments, see
Section 6.7, “GET /db/doc/attachment”.
The document data embedded in to the structure must be encoded using base64.