//将base64转换为blob
const dataURLtoBlob = (dataurl) => {
var arr = dataurl.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], { type: mime });
};
//将blob转换为file
const blobToFile = (theBlob, fileName) => {
theBlob.lastModifiedDate = new Date();
theBlob.name = fileName;
return theBlob;
};
//调用
var blob = dataURLtoBlob(info.file.response.data.base64);
var file = blobToFile(blob, "xxx.png");
console.log("当前的文件",file);
05-15
4521
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-19
3906
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-26
1851
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-27
1570
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)