/** * Manipulation des images */ class FileUtils { /** * Returns a blob with the given data and the image filetype * * @param data * @param filetype */ public static newBlob(data: string, filetype: string = 'image/jpeg'): Blob { return new Blob([data as BlobPart], {type: filetype}); } /** * Transforme un Blob en Base64 * @param {Blob} blob */ public static async blobToBase64(blob: Blob): Promise { return new Promise((resolve, _) => { const reader = new FileReader(); // @ts-ignore reader.onloadend = () => resolve(reader.result); reader.readAsDataURL(blob); }); } } export default FileUtils