Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tilgovi/960094 to your computer and use it in GitHub Desktop.
Save tilgovi/960094 to your computer and use it in GitHub Desktop.
spec for specifying custom headers on attachments in couchdb
INLINE ATTACHMENT
{
_attachments: {
"awesome.jpeg": {
content_type: "image/jpeg",
data: "base64 data goes here",
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Max-Age": "86400",
"Whatever-You-Want": "Gets stored"
}
}
}
}
STANDALONE ATTACHMENT
PUT /db/id/awesome.jpeg?rev=2-c9b53a4004d3ef5dc290bbb06c672e61 HTTP/1.1
Host: localhost
Accept: */*
Content-Type: image/jpeg
Content-Length: 424129
X-Couch-Attachment-Header: Access-Control-Allow-Origin: *
X-Couch-Attachment-Header: Access-Control-Allow-Methods: GET, POST, OPTIONS
X-Couch-Attachment-Header: Access-Control-Allow-Headers: Content-Type
X-Couch-Attachment-Header: Access-Control-Max-Age: 86400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment