Skip to content

Commit 8b07493

Browse files
authored
Merge pull request #1548 from nrkno/fix/base64-image-input
2 parents 0d1552d + ce33333 commit 8b07493

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/webui/src/client/lib/Components/Base64ImageInput.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@ export function Base64ImageInputControl({
2020
const { t } = useTranslation()
2121

2222
const handleSelectFile = useCallback(
23-
(fileContent: string) => {
24-
if (typeof fileContent !== 'string' || !fileContent) return
23+
(_fileContent: string, file: File) => {
24+
if (!file) return
2525

26-
handleUpdate(fileContent)
26+
const reader = new FileReader()
27+
reader.readAsDataURL(file)
28+
reader.onload = () => {
29+
handleUpdate(reader.result as string)
30+
}
31+
reader.onerror = (error) => {
32+
console.error('Error reading file:', error)
33+
}
2734
},
2835
[handleUpdate]
2936
)

0 commit comments

Comments
 (0)