Creating two revisions when create document with attachments

25 views
Skip to first unread message

PRASANNA KUMAR

unread,
Jun 9, 2015, 5:38:43 AM6/9/15
to mobile-c...@googlegroups.com
Hi There,

Why android CBL is creating two revisions when creating new/update document with attachments?

                                             OR

How we can create document long with attachment at the same time make sure that should have one revision?

More Details :

This is way of i'm creating document 

Document auditDocument = couchDataBase.createDocument();

auditDocument.putProperties(auditCreateAndUpdate.createAndUpdate(edAudits));


Opps: Here document is creating one revision


Here i'm updating the attachments to above document



UnsavedRevision uploadAttachments = null;

Document document;


try{

uploadAttachments = auditDocument.getCurrentRevision().createRevision();

}catch(Exception ex){

document = auditDocument;

return;

}


Bitmap signatureBitmap = edAuditSignature.getBitmapSignatureImage();

ByteArrayOutputStream bos = new ByteArrayOutputStream(); 

signatureBitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);

byte[] bitmapdata = bos.toByteArray();

try {

uploadAttachments.setAttachment(edAuditSignature.getSignatureImageName(),

"image/png", new ByteArrayInputStream(bitmapdata));

uploadAttachments.save(true);

} catch (Exception e1) {

e1.printStackTrace();


Opps: Here also document is creating one more revision


So that for single document it is creating two revision but ios/ipad(Objective-c) creating only one revision for both cases


How we can solve this problem?


Thank's


Jens Alfke

unread,
Jun 9, 2015, 1:26:02 PM6/9/15
to mobile-c...@googlegroups.com
Don’t call putProperties until after you’ve added the attachments (and whatever other properties you want.)

Document auditDocument = couchDataBase.createDocument();
rev = auditDocument.createRevision();
rev.setAttachment(…)
rev.save()

—Jens


PRASANNA KUMAR

unread,
Jun 10, 2015, 2:48:36 AM6/10/15
to mobile-c...@googlegroups.com
Thanks Jens

-Prasanna
Reply all
Reply to author
Forward
0 new messages