| 123456789101112131415161718192021222324252627 |
- /**
- * Manipulation des images
- */
- const FileUtils = {
- /**
- * Returns a blob with the given data and the file's type
- *
- * @param data
- * @param filetype
- */
- newBlob(data: BlobPart, filetype: string = 'image/jpeg'): Blob {
- return new Blob([data], { type: filetype })
- },
- /**
- * Transforme un Blob en Base64
- * @param {Blob} blob
- */
- blobToBase64(blob: Blob): Promise<string> {
- return new Promise((resolve, _reject) => {
- const reader = new FileReader()
- reader.onloadend = () => resolve(reader.result as string)
- reader.readAsDataURL(blob)
- })
- }
- }
- export default FileUtils
|