Snippets Collections
const dataUri = 'data:image/png;base64,iVBORw0KGg...';

const matches = dataUri.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/);
const type = matches[1];
const buffer = new Buffer.from(matches[2], 'base64');

fs.writeFileSync('image.png', buffer, { encoding: 'base64' });
star

Fri Dec 16 2022 11:40:26 GMT+0000 (Coordinated Universal Time)

#nodejs #datauri

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension