Get Attachments Data

20 views
Skip to first unread message

Daniel Rodriguez

unread,
Oct 31, 2014, 9:02:43 AM10/31/14
to light...@googlegroups.com
Hello guys/gals, 

I am currently working with the latest release of the API (0.1.3). 

Here is my code snippet: 

Map<String, Attachment> doc = __couchDbClientPt.find(Document.class, planId).getAttachments();
return doc.get("connectivityMatrix.json").getData();

When I try to get the attachment content through Attachment.getData() I am always getting null in return. 

Is there any other way to retrieve attachment data or is that the API does not provide the means for it? Apart from the byteArray-to-file reconstruction of attachments...

Thank you in advance

Daniel
 

Ahmed Yehia

unread,
Oct 31, 2014, 9:19:23 AM10/31/14
to light...@googlegroups.com
By default, attachment data isn't returned, you need to request it along with the document.
The way to do that, by adding a parameter to find(), eg:

Map<String, Attachment> doc = __couchDbClientPt.find(Document.class, planId, new Params().attachments()).getAttachments();

HTH

Daniel Rodriguez

unread,
Oct 31, 2014, 10:37:58 AM10/31/14
to light...@googlegroups.com
Hi Ahmed, 

Thank you for your support. It worked. 

KR
Reply all
Reply to author
Forward
0 new messages