I have Base64-encoded binary data in a string:
const contentType = \'image/png\';
const b64Data = \'iVBORw0KGg
If you can stand adding one dependency to your project there's the great blob-util npm package that provides a handy base64StringToBlob
function. Once added to your package.json
you can use it like this:
import { base64StringToBlob } from 'blob-util';
const contentType = 'image/png';
const b64Data = 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
const blob = base64StringToBlob(b64Data, contentType);
// Do whatever you need with your blob...