📜  typescript blob 到 base64 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:26.635000             🧑  作者: Mango

代码示例1
You can do it by using FileReader as follows: 

convertBlobToBase64 = (blob) => new Promise((resolve, reject) => {
    const reader = new FileReader;
    reader.onerror = reject;
    reader.onload = () => {
        resolve(reader.result);
    };
    reader.readAsDataURL(blob);
});

const base64String = await convertBlobToBase64(blob);