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

Function fileToBase64

testing/e2e/src/components/VideoGenUI.tsx:21–40  ·  view source on GitHub ↗
(file: File)

Source from the content-addressed store, hash-verified

19}
20
21function fileToBase64(file: File): Promise<string> {
22 return new Promise((resolve, reject) => {
23 const reader = new FileReader()
24 reader.onload = () => {
25 const result = reader.result
26 if (typeof result !== 'string') {
27 reject(new Error('Unexpected FileReader result'))
28 return
29 }
30 const base64 = result.split(',')[1]
31 if (!base64) {
32 reject(new Error(`Unexpected data URL format: ${result.slice(0, 32)}…`))
33 return
34 }
35 resolve(base64)
36 }
37 reader.onerror = () => reject(new Error('Failed to read file'))
38 reader.readAsDataURL(file)
39 })
40}
41
42export function VideoGenUI({
43 provider,

Callers 1

handleGenerateFunction · 0.70

Calls 1

rejectFunction · 0.85

Tested by

no test coverage detected