I am trying to use FileSaver.js to download PNG files that are served from my express application. Files are sent as base64 encoded strings, but when I try to use FileSaver.js to save them, they get corrupted.
This is how I try to save them:
var blob = new Blob([base64encodedString], {type: "data:image/png;base64"}); saveAs(blob, "image.png");
I also used this way of saving images, but it does not work if base64encodedString gets too big:
var download = document.createElement('a'); download.href = 'data:image/png;base64,' + base64encodedString; download.download = 'reddot.png'; download.click();
What am I doing wrong with FileSaver.js?
source share