How to Add attachments to currentRevision While creating new Document

8 views
Skip to first unread message

prasanna kumar

unread,
Jun 5, 2014, 7:35:03 AM6/5/14
to mobile-c...@googlegroups.com
Hi All,

While creating the new document first need to create the document by using this document we need create new revision for upload the attachments.I think where it is taking some time when we have an attachment size is 14mb.

How can we create an attachment for document.getCurrentRevision();

Document document = database.createDocument();

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("_id", id);
        properties.put("text", text);
        properties.put("check", Boolean.FALSE);
        properties.put("created_at", currentTimeString);
        document.putProperties(properties);
        AssetManager asset = getAssets();
        try{
            InputStream inputStream = asset.open("c.jpeg");
            InputStream inputStream1 = asset.open("a.jpg");
            InputStream inputStream2 = asset.open("d.jpg");
            InputStream inputStream3 = asset.open("e.jpeg");
          
           UnsavedRevision doc2UnsavedRev = document.createRevision();
            doc2UnsavedRev.setAttachment("index.jpg","image/jpeg", inputStream);
            doc2UnsavedRev.setAttachment("a.jpg","image/jpg", inputStream1);
            doc2UnsavedRev.setAttachment("d.jpg","image/jpg", inputStream2);
            doc2UnsavedRev.setAttachment("e.jpg","image/jpeg", inputStream3);

            SavedRevision doc2Rev = doc2UnsavedRev.save();

        }catch(Exception e){}

is there any alter native solution for this..or how can we  create like key and value (properties.put("_attachments", inputStream);)

could i get help or any suggestions.

Thank's
prasanna
Reply all
Reply to author
Forward
0 new messages