Closed deadlyfingers closed 8 years ago
Seems "Canvas.toBlob()" not available for Chrome / Safari - https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#Browser_compatibility so will have to convert resized Base64 image to blob.
Created image helper to display blob images with Polymer iron-image. Will be using the base64toblob script - https://github.com/miguelmota/base64toblob/blob/master/base64toblob.js
PouchDB stores attachments using "the most efficient way", but you request how you want to fetch the attachment:- "{attachments: true} option that returns the attachments base64-encoded strings. If you add {binary: true}, though, they will return Blobs/Buffers."
So we should be storing attachments in PouchDB as blob (regardless), but then we can request saved images as a base64 attachment for convenient display in web view.
Related links on PouchDB attachments: http://pouchdb.com/guides/attachments.html https://github.com/nolanlawson/blob-util
@yaronyg: From what I understand PouchDB will take an image attachment as a base64 string (albeit stripped of the "data:image\/jpeg;base64," header text) and store it in the most efficient way (ie. blob). Then it's up to the client what attachment type they wish to request - base64 string / blob. To confirm all this I would like to review the Pouch database files but I can't get the PouchDB chrome extension to work with the iframe app... Now as far as the browser is concerned base64 images are a lot easier to work with so I would prefer to request that type using the cards API route on Express. My suggestion is that we can continue to use base64 images for display and if the issue only concerns storage that we could close this issue as blob storage is apparently handled for free on the PouchDB side.
That's fine. Let's first get things working at all and then we can do perf issues. :)
Need to switch from base64 encoded images to smaller blob attachments for PouchPB save and replication.