java - Retrieve JSON attachment and its attributes -


background: have stored json document (id: 160d7237a5fd00501f4654a6c8b42f38) in cloudantdb , put attachment against document. can see below json structure has 1 attachment (i.e. rajiv.jpg) associated it.

i want retrieve json attachment object (jpeg). can me how can transform below json structure java pojo class , retrieve attachment using same ? definition of pojo class. in advance.

i want show jpeg file in ui screen via webservice retrive jpeg cloudantdb , pass ui.

{   "_id": "160d7237a5fd00501f4654a6c8b42f38",   "_rev": "3-695e52989827cd9e203ff9f506eaf7df",   "customer_id": "2",   "_attachments": {     "rajiv.jpg": {       "content_type": "image/jpeg",       "revpos": 2,       "digest": "md5-/78izjpuu7nkbvbsxbf2xg==",       "length": 39712,       "stub": true     }   } } 

the json you've got doesn't include actual attachment - metadata it.

from documentation:

to retrieve attachment, make request https://$username.cloudant.com/$database/$document_id/$attachment. body of response raw content of attachment.

so in case sounds you'd make request https://[...].cloudant.com/[...]/160d7237a5fd00501f4654a6c8b42f38/rajiv.jpg

the documentation seems confusing whether response json base64 data, or data - try , see.

you don't need pojo parse original data shown in question; whatever parser use provide "dynamic" view allowing fetch fields name: fetch _attachments field, , iterate on fields within resulting object.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -