MCPcopy Create free account
hub / github.com/TanStack/ai / fileToBase64

Function fileToBase64

testing/e2e/src/components/ImageGenUI.tsx:20–34  ·  view source on GitHub ↗
(file: File)

Source from the content-addressed store, hash-verified

18}
19
20function fileToBase64(file: File): Promise<string> {
21 return new Promise((resolve, reject) => {
22 const reader = new FileReader()
23 reader.onload = () => {
24 const result = reader.result
25 if (typeof result !== 'string') {
26 reject(new Error('Unexpected FileReader result'))
27 return
28 }
29 resolve(result.split(',')[1] ?? '')
30 }
31 reader.onerror = () => reject(new Error('Failed to read file'))
32 reader.readAsDataURL(file)
33 })
34}
35
36export function ImageGenUI({
37 provider,

Callers 1

handleGenerateFunction · 0.70

Calls 1

rejectFunction · 0.85

Tested by

no test coverage detected