Spaces:
Runtime error
Runtime error
File size: 621 Bytes
18cd77b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function blobToBase64(blob: Blob): Promise<string> {
return new Promise((resolve) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result as string);
reader.readAsDataURL(blob);
});
}
export const timeFormater = new Intl.DateTimeFormat('en-US', {
day: 'numeric',
month: 'short',
hour: 'numeric',
minute: 'numeric'
}).format;
export async function fetchImageBase64(url: string): Promise<string> {
const response = await fetch(url);
const blob = await response.blob();
const base64 = await blobToBase64(blob);
return base64;
}
|