GET /{db}/{doc}/{attachment}
This request retrieves the file attachment associated with the document. The raw data of the associated attachment is returned (just as if you were accessing a static file). The returned content is the same content type set when the document attachment was added to the database.
Request
Request headers
-
If-Match– Optional —Revision identifier of the requested document. Alternative to therevquery parameter -
If-None-Match—Optional—The attachment’s Base64-encoded MD5 binary digest.
Query parameters
| Name | Type | Description | Default |
|---|---|---|---|
rev
| string | Revision identifier | none |
Message body
Response
Status codes
- 200 OK – Attachment exists
- 304 Not Modified – Attachment wasn’t modified if ETag equals specified If-None-Match header
- 401 Unauthorized – Read privilege required
- 404 Not Found – Specified database, document or attachment was not found
Response headers
-
Accept-Ranges– Range request aware. Used for attachments with application/octet-stream -
Content-Encoding– Used compression codec. Available if the attachment’s content is a compressible type. -
Content-Length– Attachment size. If compression codec is used, this value represents the compressed size, not the actual size. -
Content-MD5– Base64 encoded MD5 binary digest -
ETag—Revision identifier enclosed in double quotes
Message body
The message body contains the attachment, in the format specified in the Content-Type header.
Example
Request
The following request retrieves the attachment that was added in the previous example.
GET http://localhost:59840/cookbook/LemonChicken/lcnote.txt?rev=2-6847bbc089e24db84bd0371b9c169566
Host: localhost:59840
Response
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: must-revalidate
Content-Length: 112
Content-Type: text/plain; charset=UTF-8
Date: Fri, 13 Dec 2013 22:59:25 GMT
Etag: "2-6847bbc089e24db84bd0371b9c169566"
Server: CouchbaseLite 1.486
Some notes about the Lemon Chicken recipe from testers
* This recipe is fabulous
* I wish it made more servings