Synchronise blobs using SyncGateway

Hi all,

I am currently using the Couchbase Mobile solution to synchronize data from my Couchbase Server to my local computer.
I have no problem to synchronize my JSON documents from my Couchbase Server to my local device, however, the binary documents are never synchronized. It seems that the problem I have encoutered concerns about the Blob documents.
I read about storing blobs using Attachments, as it is specified here :
The thing is that I can’t pull blobs from my server using the Sync Gateway.

I am using Couchbase Lite 1.0.4 (The Java library) and here is some of my project to synchronize my data using Sync Gateway :

Database db = null;
	try {
	  final Manager manager = new Manager(new JavaContext("data"), Manager.DEFAULT_OPTIONS);
	  db = manager.getDatabase("myDatabase");;
	  final URL url = new URL("");
	  final Replication pull = db.createPullReplication(url);

I have tried many things such as adding parameter to the Replication object (ChangeListener, CountDownLatch)… no success.

I have no error message either on my Sync Gateway console or my Eclipse console. But none of my blob is synchronized to my Couchbase Lite.

The questions is as follows : Is it possible to pull binary documents from the server to Couchbase Lite using Sync Gateway?

Thank you.



You should be able to pull attachments from Sync gateway.
Do you get the document but not the attachment? Can you sync doc without attachments?


Hi Idoguin,

I am not able to pull any attachment from Sync Gateway,
I can get all the JSON documents, but none attachment. It’s like my Sync Gateway ignore all my binary documents.

Thank you,


If you run the following curl command:

curl -X GET

Do you see the _attachment metadata in the JSON document that is returned?

You can retrieve a single attachment with the following curl

curl -X GET

You can get the document with all the attachments inlined in base64 with the following curl

curl -X GET

Let us know if one or more of these calls fails for you, with the response you get from SG.


Hi @nico34,

I would look into upgrading with the 1.1 release of Couchbase Mobile first.
A good test is to check if you can load the attachment in the browser.
Also, this tutorial might help, it’s loading images from the Places API to SG and then in a Recycler View.


Hi @andy,

When you say “mydocwithattachments”, what am I supposed to specify exactly? As you know, in Couchbase Server, we do not have attachments but either JSON documents or Binary documents. There is not necessarily a link between a JSON doc and a Binary document. How a binary document could be associated to a JSON one.
So “mydocwithattachments” is a Binary document ID (of CouchbaseServer)?

@jamiltz, I would say the same thing, what attachment am I supposed to put in the GET request? And about the tutorial, I am not working on an Android project, but I checked the Java code lines about the pull replication, it’s quite the same things that I have.

Thank you both.

@andy I tried the GET
using a binary document ID from Couchbase Server, and the result is :
“error”: “not_found”,
“reason”: “missing”

I waited for the SG views to finish (_design/sync_gateway, and _design/sync_housekeeping).

However, when I use a JSON Document ID, I can get it ! The answer is the JSON Document :

"_id": “0000e8054dbb4a2a8be42f4155b33c86”,
“current”: {
“name”: “nico”,
“age”: “15”, …


I had incorrectly assumed that you had stored the binary/blobs as attachments to JSON document and pushed them to sync gateway through the REST API, as per the link you posted.

Using attachments is the correct way to store and retrieve binary data via Sync Gateway.

If you are storing simple key/value data directly in Couchbase Server, Sync Gateway will not see these and there is no way to request them via the Sync Gateway REST API.


@Andy Exactly, I have directly store blobs in Couchbase Server. I don’t think there is a way to store binary data as JSON attachment in Couchbase Server isn’t it ? I have looked for it but it seems that we can only store binary data as I’ve done and like it’s explained here :

I am actually making the link myself in my JSON documents, by adding a field containing a blob ID.

Thank you again.