We have two sets of attachment documents in couchbase server , one is created by Mobile(couchbase Lite) which looks like as below
{
2C3KA63H88H294740-7.jpg: {
@type: “blob”,
content_type: “image/jpeg”,
digest: “sha1-VtRRBo+zPVZCxOdMZVjBgYuVqwg=”,
length: 3231323
},
2C3KA63H88H294740-8.jpg: {
@type: “blob”,
content_type: “image/jpeg”,
digest: “sha1-kG4Jz6LV7OB30s1e/h9R0pRHUMM=”,
length: 2924523
},
attachments: {
blob/2C3KA63H88H294740-7.jpg: {
content_type: “image/jpeg”,
digest: “sha1-VtRRBo+zPVZCxOdMZVjBgYuVqwg=”,
length: 6417888,
revpos: 9,
stub: true
},Preformatted text
blob_/2C3KA63H88H294740-8.jpg: {
content_type: “image/jpeg”,
digest: “sha1-kG4Jz6LV7OB30s1e/h9R0pRHUMM=”,
length: 2924523,
revpos: 9,
stub: true
}
}
However, if document is created from AdmiAPI
{
attachments: {
blob/2C3KA63H88H294740-7.jpg: {
content_type: “image/jpeg”,
digest: “sha1-VtRRBo+zPVZCxOdMZVjBgYuVqwg=”,
length: 6417888,
revpos: 9,
stub: true
},Preformatted text
blob_/2C3KA63H88H294740-8.jpg: {
content_type: “image/jpeg”,
digest: “sha1-kG4Jz6LV7OB30s1e/h9R0pRHUMM=”,
length: 2924523,
revpos: 9,
stub: true
}
}
It does not seem to be adding any top section while adding through admin API. which was not really problem in terms of storage; however, document added through AdminAPI when it is being sync’ed to Mobile device. Couchbaselite SDK uses other section to download the image.
Blockquote
InputStream is = getAsset(“avatar.jpg”);
if (is == null) { return; }
try {
Blob blob = new Blob(“image/jpeg”, is);
newTask.setBlob(“avatar”, blob);
database.save(newTask);
Blob taskBlob = newTask.getBlob("avatar");
byte[] bytes = taskBlob.getContent();
} catch (CouchbaseLiteException e) {
Log.e(TAG, e.toString());
} finally {
try { is.close(); }
catch (IOException ignore) { }
}
I am looking for some kind of implementation for CBL so attachments could be downloaded (It is one way sync from server to mobile)
Any help is greatly appreciated.