I am trying to save a blob to localforage and then retrieve it and display it. It works fine for a while, but after a couple of page refreshes or browser closes I get an error on some of the blobs. The complete error is as follows:
Failed to load resource: The operation couldn’t be completed. (WebKitBlobResource error 1.)
Here is the rest of my code. Save item to localforage:
canvas.toBlob(function(blob){
allItems.push({"string":string,"blob":blob});
localforage.setItem("savedItems",allItems);
},"image/jpeg",0.02);
Load item from localforage:
localforage.getItem("savedItems").then(function(jsonData){
if(jsonData==null){allItems=[];}
else{allItems=jsonData;}
});
Add blob to image source:
let thisURL = window.URL || window.webkitURL;
let url=thisURL.createObjectURL(allItems[k]['blob']);
img.src=url;
This seems to be a Safari specific problem, as I am not able to replicate it in Chrome.