I'm trying to convert a blob (created with zip.js) to a base64 and persist it in the websql database. Then I would also like to do this process the other way around. Anyway, my test code (without the compression) looks something like:
var blob = new Blob([data], {
type : "text/plain"
});
blobToBase64(blob, function(b64) { // convert BLOB to BASE64
var newBlob = base64ToBlob(b64) ; // convert BASE64 to BLOB
console.log(blob.size + " != " + newBlob.size) ;
});
see a working example: http://jsfiddle.net/jeanluca/4bn5G/
So, the strange thing is, that it works in Chrome, but not in Safari (als not on my iPad).
I also tried to rewrite the base64ToBlob to
function base64ToBlob(base64) {
var binary = atob(base64);
return new Blob([binary]) ;
}
But then de uncompress doesn't work anymore, giving me an "IndexSizeError: DOM Exception 1 " exception
Any suggestion what might be wrong in my code ?
Thnx