Answer: Creating a BLOB from a Base64 string in JavaScript

rnagarajan96

Nagarajan R

Posted on September 15, 2020

Answer: Creating a BLOB from a Base64 string in JavaScript

For all copy-paste lovers out there like me, here is a cooked download function which works on Chrome, Firefox and Edge:

window.saveFile = function (bytesBase64, mimeType, fileName) {
var fileUrl = "data:" + mimeType + ";base64," + bytesBase64;
fetch(fileUrl)
    .then(response => response.blob())
    .then(blob => {
        var link = window.document.createElement("a");
        link.href
💖 💪 🙅 🚩
rnagarajan96
Nagarajan R

Posted on September 15, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related