Download src/utils/convert-image-to-base-64.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 288 Bytes
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/src/utils/convert-image-to-base-64.ts
- Command line
-
hf download hf://SaylorTwift/openhands/src/utils/convert-image-to-base-64.ts
-
curl -L -o convert-image-to-base-64.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/src/utils/convert-image-to-base-64.ts
288 Bytes
| export const convertImageToBase64 = (file: File): Promise<string> => | |
| new Promise((resolve, reject) => { | |
| const reader = new FileReader(); | |
| reader.onloadend = () => { | |
| resolve(reader.result as string); | |
| }; | |
| reader.onerror = reject; | |
| reader.readAsDataURL(file); | |
| }); | |