mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 20:35:19 +00:00
refac/fix: kb image upload handling
This commit is contained in:
parent
e986488ab5
commit
f524a6a8e7
3 changed files with 16 additions and 7 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"
|
request.app.state.config.CONTENT_EXTRACTION_ENGINE == "external"
|
||||||
):
|
):
|
||||||
process_file(request, ProcessFileForm(file_id=file_item.id), user=user)
|
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:
|
else:
|
||||||
log.info(
|
log.info(
|
||||||
f"File type {file.content_type} is not provided, but trying to process anyway"
|
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);
|
console.error(data.error);
|
||||||
res.error = data.error;
|
res.error = data.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (res?.data) {
|
||||||
|
res.data = data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -184,12 +184,6 @@
|
||||||
|
|
||||||
if (uploadedFile) {
|
if (uploadedFile) {
|
||||||
console.log(uploadedFile);
|
console.log(uploadedFile);
|
||||||
|
|
||||||
if (uploadedFile.error) {
|
|
||||||
console.warn('File upload warning:', uploadedFile.error);
|
|
||||||
toast.warning(uploadedFile.error);
|
|
||||||
}
|
|
||||||
|
|
||||||
knowledge.files = knowledge.files.map((item) => {
|
knowledge.files = knowledge.files.map((item) => {
|
||||||
if (item.itemId === tempItemId) {
|
if (item.itemId === tempItemId) {
|
||||||
item.id = uploadedFile.id;
|
item.id = uploadedFile.id;
|
||||||
|
|
@ -199,7 +193,14 @@
|
||||||
delete item.itemId;
|
delete item.itemId;
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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);
|
await addFileHandler(uploadedFile.id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toast.error($i18n.t('Failed to upload file.'));
|
toast.error($i18n.t('Failed to upload file.'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue