Spaces:
Paused
Paused
File size: 485 Bytes
7249a2e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
export function blobToBase64Uri(blob?: Blob): Promise<string> {
return new Promise((resolve, reject) => {
if (!blob || typeof window === "undefined" || !window.FileReader) {
resolve("")
return
}
const reader = new window.FileReader()
reader.readAsDataURL(blob)
reader.onloadend = () => {
resolve(`${reader.result || ""}`)
}
reader.onerror = () => {
// reject("error while converting blob to base64")
resolve("")
}
})
} |