从无法访问的项目Fork
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
/** * @description: base64 to blob */ export function dataURLtoBlob(base64Buf: string): Blob { const arr = base64Buf.split(','); const typeItem = arr[0]; const mime = typeItem.match(/:(.*?);/)![1]; const bstr = atob(arr[1]); let n = bstr.length; const u8arr = new Uint8Array(n); while (n--) { u8arr[n] = bstr.charCodeAt(n); } return new Blob([u8arr], { type: mime }); }