pouchdb inline attachment – saving and retrieving-open source projects pouchdb/pouchdb

I’m trying to use pouchdb to save an image which has been encoded in base64 format as an attachment against a document (inline) and then retrieve it again.

However, when i retrieve the document it seems as though pouchdb has modified the base64 image data and has appended ‘md5-‘ to it. There is also no ‘data’ attribute off of the attachment object, as i would have expected. Instead i find an object called ‘digest’. What is this?

I have created an example:

var db = new PouchDB('example');
db.bulkDocs(
    [
      {
        _id: '1', 
        name: 'example',
        "_attachments": {
            "avatar.jpg": {
                "content_type": "image/jpg",
                "data": [BASE65 DATA STRING]
        }
      }
    ], 
    function(err, response) {
      if (!err) {
        db.allDocs({ include_docs: true, attachments: true }, function(err, docs) {
            var d  = docs.rows[0].doc;
            // d looks like this: 
            // {"name":"example","_attachments":{"avatar.jpg":{"content_type":"image/jpg","digest":"md5-57e396baedfe1a034590339082b9abce","stub":true}},"_id":"1","_rev":"1-ff23a959ae88b871b94374a784a07728"}
        });
      }
    }
);

Full example can be found here: http://jsfiddle.net/ntan0ycL/

How would i go about retrieving the base64 representation of the image from the pouchdb document? I’m not sure if the problem lies in how i’m saving the attachment or how i’m retrieving it.

Thanks,

Andrew.