If you’re updating an attachment via a PUT to the attachment’s URL, the HTTP body is literally the exact attachment data. So in your case it would be raw JPEG image data.
I’m using react-native and blobUtil doesn’t seem to work. If I had an example of what the body should look like I’m sure I can figure out a solution, but I can’t find an example.
Thanks. Unfortunately the code above doesn’t seem to work in react-native. Do you have an example of what the binaryString looks like? I’m trying to reverse engineer what these libraries do to see if I can come up with an alternative.
I’ve given up trying to do it in javascript. It was beginning to feel solving it in react-native was going to take long than the universe has left to live
Is there a java example of posting a binary attachment to the sync-gateway? Or any example it it working in any other language?
Would it be possible to add a new endpoint to the rest api? I want to be able to send a file using a standard js library, but they all seem to use a multipart form data http body, rather than just a stream of bytes.
Multipart is optional for the single-document APIs. You can send the doc as JSON by using ContentType: application/json, and you can request responses in JSON using Accept: application/json (in fact I think that’s the default?)
I showed a very simple example above of uploading an attachment by itself.