(url: string)
| 42 | } |
| 43 | |
| 44 | export async function fetchFileBASE64(url: string): Promise<string> { |
| 45 | const response = await fetch(url); |
| 46 | const arrayBuffer = await response.arrayBuffer(); |
| 47 | const bytes = new Uint8Array(arrayBuffer); |
| 48 | let binary = ""; |
| 49 | for (let i = 0; i < bytes.byteLength; i++) { |
| 50 | binary += String.fromCharCode(bytes[i]); |
| 51 | } |
| 52 | return btoa(binary); |
| 53 | } |
| 54 | |
| 55 | export function isBASE64Data(value: string): boolean { |
| 56 | return typeof value === "string" && /^data:/.test(value); |