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 : http://developer.couchbase.com/mobile/develop/guides/couchbase-lite/native-api/attachment/index.html
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");
db.open();
final URL url = new URL("http://127.0.0.1:4984/myDatabase");
final Replication pull = db.createPullReplication(url);
pull.start();
...
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?
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.
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.
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.
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 : http://docs.couchbase.com/developer/java-2.1/documents-basics.html
I am actually making the link myself in my JSON documents, by adding a field containing a blob ID.