Moving a BLOB(attachment) from one document to another

Let me illustrate the flow. ‘a’ means alpha symbol; ‘b’ means beta symbol in the illustrations

  1. User takes a picture. Our Xamarin program creates 2 new documents: ‘a’ and ‘b’. Both of them have a BLOB attachment created through Couchbase Lite (notice that the document icon has another little document icon inside). Notice that both of them have value 1AB2 in RelaField but the type is different: ‘a’ is newdoc while ‘b’ is doc.

  1. Both documents are propagated to Couchbase Capella.
  2. Connector.NET is a daemon asking every x seconds if there is any newdoc.
  3. In this case, the answer is ‘yes, ‘a’‘.
  4. So Connector.NET makes an API call with the data contained in ‘a’
  5. The API method inserts a new record in a Postgre table (a new id is created, let’s say 6589)

  1. Connector.NET deletes ‘a’ as it is already processed
  2. Connector.NET queries a table called Queue
  3. Connector.NET gets the newly created row with the new id (6589, as said in step 6)
  4. Connector.NET creates a new document in Couchbase Capella with id ‘document::6589’. Notice that it has no attachment
  5. Connector.NET gets the attachment of ‘b’.

The goal is that Connector puts attachment of ‘b’ into ‘document::6589’ and then deletes ‘b’(using RelaField to find a match). I see 2 options:
a) Move attachment from ‘b’ to ‘document::6589’.
b) Create a new attachment for ‘document::6589’ with the Stream get on step 11

Both options must be done using API as Connector.NET does not have CouchbaseLite.

1 Like

What is the question?

a) How can I move an attachment from one document to another through API? Is there any curl command I can run to move one attachment from one document to another?.

b) How can I add an attachment from a Stream through API? I mean, suppose I have a file called ‘landscape.jpg’ and I want to upload to Couchbase as an attachemnt. The file only exists in my PC. How could I upload to Couchbase? Which would be the curl command?

I have read the documentation(Handle Binary Data Attachments & Blobs with Couchbase Mobile - The Couchbase Blog) once and over again and I am not able to figure out how to do any of above points.

1 Like

Does anybody have any idea?

Public REST API | Couchbase Docs

Click on Document Attachment to see the APIs - Public REST API | Couchbase Docs

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.