I am trying to package several png data in base64 format.
The code runs on the client, and it is supposed to generate a zip file for download with png files. The code below works fine except that all the png in the zip are "corrupt".
I gather that they are not in the right format when they are passed to the client-zip. Though I have not been able to find how to convert and pack them in the right way, also including the metadata as in the text examples I found online.
What is the right way of converting and packaging these files?
Staring the obvious, below, each variable content holds a string of the form:
"data:image/png;base64,iVBORw0KGgoAA..."
function addImageData(index){
let fileName = "file_".concat(timePoints[index].concat(".png"));
let content = o.png();
snapshotArray.push({ name: fileName,
lastModified: new Date(),
input: content });
}
async function downloadMyZip() {
const blob = await downloadZip(snapshotArray).blob()
const link = document.createElement("a")
link.href = URL.createObjectURL(blob)
var today = new Date();
link.download = "images_".concat(today.toString()).concat(".zip")
link.click()
link.remove()
}