mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 12:55:19 +00:00
refac/fix: kb image upload handling
This commit is contained in:
parent
5732ee7021
commit
8dce54f3fc
3 changed files with 18 additions and 9 deletions
|
|
@ -115,6 +115,10 @@ def process_uploaded_file(request, file, file_path, file_item, file_metadata, us
|
|||
request.app.state.config.CONTENT_EXTRACTION_ENGINE == "external"
|
||||
):
|
||||
process_file(request, ProcessFileForm(file_id=file_item.id), user=user)
|
||||
else:
|
||||
raise Exception(
|
||||
f"File type {file.content_type} is not supported for processing"
|
||||
)
|
||||
else:
|
||||
log.info(
|
||||
f"File type {file.content_type} is not provided, but trying to process anyway"
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@ export const uploadFile = async (token: string, file: File, metadata?: object |
|
|||
console.error(data.error);
|
||||
res.error = data.error;
|
||||
}
|
||||
|
||||
if (res?.data) {
|
||||
res.data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,12 +185,6 @@
|
|||
|
||||
if (uploadedFile) {
|
||||
console.log(uploadedFile);
|
||||
|
||||
if (uploadedFile.error) {
|
||||
console.warn('File upload warning:', uploadedFile.error);
|
||||
toast.warning(uploadedFile.error);
|
||||
}
|
||||
|
||||
knowledge.files = knowledge.files.map((item) => {
|
||||
if (item.itemId === tempItemId) {
|
||||
item.id = uploadedFile.id;
|
||||
|
|
@ -200,10 +194,17 @@
|
|||
delete item.itemId;
|
||||
return item;
|
||||
});
|
||||
if (syncMode) {
|
||||
await syncFileHandler(uploadedFile.id);
|
||||
|
||||
if (uploadedFile.error) {
|
||||
console.warn('File upload warning:', uploadedFile.error);
|
||||
toast.warning(uploadedFile.error);
|
||||
knowledge.files = knowledge.files.filter((file) => file.id !== uploadedFile.id);
|
||||
} else {
|
||||
await addFileHandler(uploadedFile.id);
|
||||
if (syncMode) {
|
||||
await syncFileHandler(uploadedFile.id);
|
||||
} else {
|
||||
await addFileHandler(uploadedFile.id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
toast.error($i18n.t('Failed to upload file.'));
|
||||
|
|
|
|||
Loading…
Reference in a new issue