Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decode attachments returned from get-document #49

Closed
dehubbed opened this issue Feb 22, 2012 · 3 comments
Closed

decode attachments returned from get-document #49

dehubbed opened this issue Feb 22, 2012 · 3 comments

Comments

@dehubbed
Copy link

it seems "get-document" fetches attachments included with the document, however they are not decoded into binary. as an analogy to "put-document" which accepts binary attachments get-document should sort of present the "reverse" interface and decode them?

right now I can make use of "put-document" to add any number of attachments to a document in one go (call it bulk-attach if you want to) but in order to retrieve them as binary I have to retrieve them one by one using get-attachment.

thank you

@cemerick
Copy link
Contributor

cemerick commented May 4, 2012

get-document does not return a document's attachments: they must be retrieved via get-attachment, which does perform all the necessary decoding.

@cemerick cemerick closed this as completed May 4, 2012
@dehubbed
Copy link
Author

dehubbed commented May 4, 2012

The get-document doc-string says something about attachments: https://github.com/clojure-clutch/clutch/blob/master/src/com/ashafa/clutch.clj#L167, also see here: http://wiki.apache.org/couchdb/HTTP_Document_API#Getting_Attachments_With_a_Document

It's been a while since I opened this issue but I seem to remember successfully getting attachments with a doc. This saves HTTP roundtrips when having several smallish attachments. For that case, smallish attachments, I now recommend just using plain base64 encoded fields in the main doc instead of attachments, less fuzz except you have to decode 'manually'.

@cemerick
Copy link
Contributor

cemerick commented May 4, 2012

Oh, good point. I've never used this, simply because the attachments are returned base64-encoded, an obviously inefficient situation.

In any case, automatically decoding that data wouldn't be appropriate; for all I know, a perfectly good use case involves moving that attachment data around in its encoded form.

A more interesting prospect is supporting the MIME multipart/related feature described in the HTTP document API section you linked to; gh-57 will track that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants