We are trying to create a utility where the data is taken from legacy system converted into JSON and put onto sync gateway which is having a couch base bucket connected to it. All well went until its about attachment.
We are using HttpClient of .net and using rest API of sync gateway. The problem is, we are able to put document by converting image in base64 string content. but when we try get call using fiddler the image doesn’t come back. It says Not an image [image/png]. Ad following is the raw data :- HTTP/1.1 200 OK
Server: Couchbase Sync Gateway/1.4
Date: Tue, 02 May 2017 09:46:49 GMT
You can use curl to see how to add binary attachments using curl, then you can compare with the request generated from from your .net code.
Assuming you have a JPG file on your local client called attach-test.jpg, and you have a document already stored in a DB in Sync Gateway called doc1 at rev1, the following curl command should add the image as an attachment:
curl -vX PUT http://127.0.0.1:4985/db/doc1/attach-test.jpg?rev=rev=1-cd809becc169215072fd567eebd8b8de --data-binary @attach-test.jpg -H "Content-Type: image/jpg"
Then you should see a response similar to the following if you get the document back: