but when we create .pdf file and .jpeg file it gives success. But when we try to open it it gives error on pdf that “Invalid Format " and on jpeg image it gives " Oops! Couldn’t load this image”.
I tried to open these file manually and by programmatically. but the error was same.
var contentType="image/jpeg";
var slizeSize=512;
var URI = succ.URI;
var block = URI.split(";");
// var dataType = block[0].split(":")[1];
// In this case "image/png"
var realData = block[1].split(",")[1];
// In this case "iVBORw0KGg...."
// console.log("Real Data : ", realData)
var byteCharacters = decodeURI(realData);
// console.log("Byte Character : ",byteCharacters)
var byteArrays = [];
for (var offset = 0; offset < byteCharacters.length; offset += slizeSize) {
var slice = byteCharacters.slice(offset, offset + slizeSize);
var byteNumbers = new Array(slice.length);
for (var i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
var blob = new Blob(byteArrays, {type: contentType});
console.log("Blob : ",blob);
This is how I am creating a blob
"succ.URI" is the base64 image data
Download the files and look at them in a text editor. Something is broken, but I would say it is probably with the blob you are writing, not the plugin. Can you maybe read in a working image and write it into a new file?