refac/perf: channel image upload behaviour
This commit is contained in:
@@ -1,16 +1,26 @@
|
||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
import { splitStream } from '$lib/utils';
|
||||
|
||||
export const uploadFile = async (token: string, file: File, metadata?: object | null) => {
|
||||
export const uploadFile = async (
|
||||
token: string,
|
||||
file: File,
|
||||
metadata?: object | null,
|
||||
process?: boolean | null
|
||||
) => {
|
||||
const data = new FormData();
|
||||
data.append('file', file);
|
||||
if (metadata) {
|
||||
data.append('metadata', JSON.stringify(metadata));
|
||||
}
|
||||
|
||||
const searchParams = new URLSearchParams();
|
||||
if (process !== undefined && process !== null) {
|
||||
searchParams.append('process', String(process));
|
||||
}
|
||||
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/files/`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/files/?${searchParams.toString()}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user