First I create a document as in the example on the couchbase site then save the document,
after that I create a new revision of the document and add the attachment to that revision and then save the new revision and the again I create a new revision and modify some properies. For replication I am using the push and pull replicator.
This is the code for retrieveing the attachment
var revision = _database.GetDocument (scene.Id).GetRevision( scene.RevisionId ); var attachment = revision.GetAttachment ("preview");
And whe replicating the document to another device the attachment is sometimes null but the attachment is in the databse folder.
If the attachment is null, I am updating the document on the original device, that is,
I create a new revision, update the properties and save the new revision and then again I create a new revision add the attachment (it is the same as the previous one) and save the revision with the attachment.
The updated document gets replicated on the other device and the I can access the attachment.