Example of accessing attachments through Sync Gateway with Java?


#1

Continuing the discussion from How can I get attachment on couchbase server via Java SDK for my system?:

Couchbase Mobile doesn’t support use of the regular Couchbase Java SDK because it adds it’s own metadata for attachments. This is covered in the documentation.

I think you’re looking for a code example of using the Sync Gateway REST interface to get to the document+attachment. Moving this to a linked topic in the other category.


#2

In fact I am getting this image from Android in Couchbase Lite, then replicate that using Sync Gateway to Couchbase Server sync_gateway bucket and move that to my “shadow” bucket, which I try to access from external system and get that image. In my “shadow” bucket I see the document with that section:

{
"_attachments": {
“2119.jpg”: {
“content_type”: “image/jpg”,
“digest”: “sha1-pGSjuuUGjHv4Y1V7/jXut7VyVdI=”,
“length”: 929737,
“revpos”: 7,
“stub”: true
}
},

and when I try to send GET to Syn Gateway: http://localhost:4984/shadow/e6689d06-6fd2-4ace-923f-f5df88f67816/2119.jpg
it shows my image.

Is that mean that I can not access my “shadow” bucket but I have to access Sync Gateway using REST to get that image?