| 1234567891011121314151617181920212223242526272829 |
- /**
- * 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<string> {
- return new Promise((resolve, _) => {
- const reader = new FileReader();
- // @ts-ignore
- reader.onloadend = () => resolve(reader.result);
- reader.readAsDataURL(blob);
- });
- }
- }
- export default FileUtils
|