PNG JPG type images are corrupted after download, but svg type images are working.
here is my code
const getFileExtension = (filename) => {
return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined;
};
const downloadCertificate = (imageName) => {
_getCertificate(imageName, (status, data) => {
if (status === "success") {
console.log(data);
const blob = new Blob([data]);
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = `certificate-${+new Date()}.${getFileExtension(imageName)}`;
link.click();
}
})
}
```