diff --git a/src/lib/components/AddConnectionModal.svelte b/src/lib/components/AddConnectionModal.svelte
index 8586c5f384..476b582e74 100644
--- a/src/lib/components/AddConnectionModal.svelte
+++ b/src/lib/components/AddConnectionModal.svelte
@@ -20,6 +20,7 @@
import Textarea from './common/Textarea.svelte';
import { normalizeTags } from '$lib/utils/tags';
import { compressImage } from '$lib/utils';
+ import { uploadFile } from '$lib/apis/files';
import { WEBUI_BASE_URL } from '$lib/constants';
export let onSubmit: Function = () => {};
@@ -61,6 +62,12 @@
let profileImageUrl = '';
let profileImageInput: HTMLInputElement;
const profileImageTypes = ['image/png', 'image/jpeg', 'image/webp', 'image/gif'];
+ // Stored as a link to the uploaded file, like model profile images.
+ $: profileImageSrc = profileImageUrl
+ ? profileImageUrl.startsWith('/')
+ ? `${WEBUI_BASE_URL}${profileImageUrl}`
+ : profileImageUrl
+ : `${WEBUI_BASE_URL}/static/favicon.png`;
const profileImageHandler = async (event: Event) => {
const input = event.currentTarget as HTMLInputElement;
@@ -248,6 +255,25 @@
}
}
+ if (profileImageUrl.startsWith('data:')) {
+ const blob = await (await fetch(profileImageUrl)).blob();
+ const uploaded = await uploadFile(
+ localStorage.token,
+ new File([blob], `profile.${blob.type.split('/')[1]}`, { type: blob.type }),
+ null,
+ false,
+ false
+ ).catch((error) => {
+ toast.error(`${error}`);
+ return null;
+ });
+ if (!uploaded?.id) {
+ loading = false;
+ return;
+ }
+ profileImageUrl = `/api/v1/files/${uploaded.id}/content`;
+ }
+
// remove trailing slash from url
url = url.replace(/\/$/, '');
@@ -421,11 +447,7 @@
aria-label={$i18n.t('Upload')}
on:click={() => profileImageInput.click()}
>
-
+
{#if profileImageUrl}
diff --git a/src/lib/components/admin/Settings/Connections/OllamaConnection.svelte b/src/lib/components/admin/Settings/Connections/OllamaConnection.svelte
index c55bf3a4c8..e672a7f823 100644
--- a/src/lib/components/admin/Settings/Connections/OllamaConnection.svelte
+++ b/src/lib/components/admin/Settings/Connections/OllamaConnection.svelte
@@ -48,7 +48,11 @@