local_db.getAttachment(id, "atticPhoto").then(function (blob) { console.log("SUCCESS getAttachment" +id);
var myImg = new Image(); myImg.onload = function() { var drawing = document.getElementById("landscape_canvas"); var context = drawing.getContext("2d"); context.save(); context.drawImage(myImg, 0, 0); };
var myUrl = URL.createObjectURL(blob); myImg.src = myUrl;// draw datalines getDataLines(id);
// handle result }).catch(function (err) { console.log("getAttachment: " +err); });
pouchdb:api ambers_app +180ms getAttachment Array[1]0: "2017-02-22T17:12:31.114Z"length: 1__proto__: Array[0] atticPhoto
pouchdb-6.1.2.js:151 pouchdb:api ambers_app +254ms getAttachment error CustomPouchErrorerror: truemessage: "missing"name: "not_found"reason: "missing"status: 404__proto__: Error
[Log] pouchdb:api ambers_app +14ms (3) (pouchdb-6.1.2.js, line 151)
"getAttachment"
"success"
Blob {size: 234756, type: "image/jpg", slice: function}
[Log] SUCCESS getAttachment2017-02-22T17:12:31.114Z (imageDrawLandscape.js, line 77)
local_db.get(id, {attachments: true}).then(function(doc) { console.log("SUCCESS GET DOC: " +id); }).then(function() { return local_db.getAttachment(id, image_id); }).then(function (blob) { console.log("SUCCESS GET attachments: " +id); var myImg = URL.createObjectURL(blob); var myCanvas = document.getElementById('landscape_canvas'); var ctx = myCanvas.getContext('2d'); var img = new Image; img.onload = function(){ ctx.drawImage(img,0,0); }; img.src = myImg;
}).catch(function (err) { console.log("ERROR getAttachment: " +err); }); getDataLines(id);