Question: how to update couchbase lite write image blob from sync_gateway restful api


#1

hi:
my team using couchbase 5.1.0 and sync_gateway 2.0,mobile sdk is android couchbase lite 2.0.
mobile sdk write attachment as blow:

the couchbase server document like is:

image

I used curl update image via sync_gateway restful api like is:

curl -u a6b6967b:123456 -vX PUT http://localhost:4985/dbname/Dishes.6fcc6477-3cc6-4537-bc2e-0c809ace664b/blob_1?rev=4-ff659e041c89bbff4ad5bf3b632644f9 --header Content-Type:image/jpg --data-binary @image.jpg

then I can get updated image from browser(chrome) request sync_gateway. but couchbase lite haven’t sync the new image. it seem the image:{xxxx} tag haven’t update. how can I resolve?

thanks!


#2

Curious - what do you get when you retrieve the blob on the Couchbase Lite side ? Please share the code. Did you retrieve using getBlob. The Sync Gateway deals with _attachment type while the blob type (which in your case is “image”) is recognized at Couchbase Lite side.


#3

hi @priya.rajagopal:

thanks for you reply.
my couchbase lite android sdk code is:


Sorry,I think haven’t descript clear my qustion.
my means android device add or change images can sync and dispaly image on other android device .
now I want use web application update or create the blob image that can sync with android.
when I use curl update image via sync_gateway restful api, then I can get updated image from web browser,but can’t sync with android.
I check the data from couchbase web console, there have two fragments record the image info. one tag is _attachments and another is image ,when I update image via sync_gateway restful api, two tag length property not equals.

how can I update image via sync_gateway restful api can update _attachments and image?

thank you again.


#4

That seems to be a bug. If you update the attachment via the SGW via the PUT API, it should update the relevant metadata that should cause it to sync over.
We have raised a ticket to track this .


#5

@priya.rajagopal thank you for reply.