Dream4ever / Knowledge-Base

record every requirement and solution here
https://www.hewei.in/
36 stars 6 forks source link

将 Base64 格式的图片转换为 Blob #217

Closed Dream4ever closed 2 years ago

Dream4ever commented 2 years ago

实现过程

Google:base64toblob

参考链接:Creating a BLOB from a Base64 string in JavaScript

核心代码:

var url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="

fetch(url)
.then(res => res.blob())
.then(console.log)