Couchbase SDK retrieve blob from app cluster

Hello,

I am using couchbase lite to save binary files for my application users.
This works great and the data is saved, I can even see the blob files in local Attachments folder.

blob = Blob.fromData('application/bindata', bytes);
mutableDoc.setBlob(blob, key: 'data');
collection.saveDocument(mutableDoc);

I need to be able to run statistical analysis on the data in the binary files, so I am trying to retrieve the blob data using Python SDK. I can query the document and I see that it contains information about the attached blob.

result = collection.get(doc_id).content_as[dict]
print(digest = result["data"]["digest"])
outputs:
{'content_type': 'application/bindata', 'digest': 'sha1-rFkdrjGqTb+Kin63wwvh7uROyek=', 'length': 387606, '@type': 'blob'}

This is great but how do I actually retrieve the binary data contained in the blob? I need to be able to query and retrieve the binary data in the blobs for all of the application users.

Thank you in advance

Hi @LucosidE please see Transcoders and Non-JSON Documents | Couchbase Docs

Hi Graham,

Thank you for the link.

However I am not trying to transcode any data differently. I have Data Sync already working in an app and saving blob data to the server. I need to be able to retrieve the blobs in python. I do not want to change in any way how the sync gateway works.

I am following Blobs | Couchbase Docs
However I do not see the added _attachements to documents I do see the equivalent of “avatar“ or in my case “data“. Also when I query the document from the DB clearly it does not contain the blob data since the result is only a few bytes.

Syncing blobs is clearly explained in the above documentation however I cannot find any documentation on how to query the blob data using the SDK.

Cheers

Hi @LucosidE,

I asked around internally, and one of the experts on the Mobile team said:

I would use a REST API with sync gateway Get an attachment from a document

We don’t have a publicly defined schema for storage and are not planning on creating one, we in fact have changed this in Sync Gateway 3.0, and Sync Gateway 4.0

Thanks,
David