Couchbase lite 2x how to get rid of blob_/ prefix for attachment? (problems when migrating from CBL 1.4)

Hello!

We are trying to migrate from Couchbase Lite 1.4 to more modern Couchbase Lite 2.8.

My experiments shows that in CBL 1.4 we got following attchment structure on server:

“_attachments”:{“imageAttachment”:{“content_type”:“image/jpeg”,“digest”:“sha1-J6kxplV+IjWE/OC1MWHjmC2PFjs=”,“length”:616251,“revpos”:3,“stub”:true}}

But in CBL 2 when I use method call:

doc.setBlob(“imageAttachment”, blob)

I got following:

attachments":{**"blob_/imageAttachment”**:{“content_type”:“image/jpeg”,“digest”:“sha1-1u4KKfNQWSqr+WnWLzZQbRl+QBM=”,“length”:616254,“revpos”:4,“stub”:true}}

My database got a lot of old CBL 1.4 images, imageAttachment name was hard coded in the API (since its a constant)
Now when I move to CBL 2 my backend cannot display CBL 2 photos since prefix blob_/ was added.

Is it possible to get rid of this prefix?

P.S.: Btw passing attachment name as a workaround is possible, but will require to add additional document fetch by id from couchbase to get attachment name. Seems like overhead for me.

Sorry, this is one of the incompatible changes between 1.x and 2.x, and this format was internal to begin with. There is nothing in there that will provide you any benefit over using the standard APIs to access the data so I recommend that you use that (in 2.x just call getBlob)

1 Like

It is what Jim said. And specifically to your question on backend access, you will have to prefix “blob_” (make sure your URL encode it)
This blog should be a helpful reference

1 Like