mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-28 06:22:33 +00:00
refac
This commit is contained in:
parent
11406c1654
commit
82d6f230b4
2 changed files with 6 additions and 2 deletions
|
|
@ -737,6 +737,9 @@ async def update_file_data_content_by_id(
|
|||
)
|
||||
|
||||
if file.user_id == user.id or user.role == 'admin' or await has_access_to_file(id, 'write', user, db=db):
|
||||
if not form_data.content.strip():
|
||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.EMPTY_CONTENT)
|
||||
|
||||
max_size = await Config.get('rag.file.max_size')
|
||||
if max_size and len(form_data.content.encode('utf-8')) > int(max_size) * 1024 * 1024:
|
||||
raise HTTPException(
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@
|
|||
data = { filePdfData: await blob.arrayBuffer() };
|
||||
else if (ext === 'svg' || mime === 'image/svg+xml') {
|
||||
previewName = `${name}.svg`;
|
||||
data = { fileContent: await blob.text() };
|
||||
data = { fileContent: await getFileIndexedText(localStorage.token, file.id!, signal) };
|
||||
sourceToggle = true;
|
||||
} else if (mime.startsWith('image/') || /^(png|jpe?g|gif|webp|avif|bmp|ico)$/.test(ext)) {
|
||||
objectUrl = URL.createObjectURL(blob);
|
||||
|
|
@ -154,7 +154,7 @@
|
|||
) ||
|
||||
mime.includes('json')
|
||||
) {
|
||||
data = { fileContent: await blob.text() };
|
||||
data = { fileContent: await getFileIndexedText(localStorage.token, file.id!, signal) };
|
||||
if (mime === 'text/csv' && ext !== 'csv') previewName = `${name}.csv`;
|
||||
if (mime === 'text/html' && !/^html?$/.test(ext)) previewName = `${name}.html`;
|
||||
if (mime.includes('json') && !/^(json|jsonc|jsonl|json5|ipynb)$/.test(ext))
|
||||
|
|
@ -205,6 +205,7 @@
|
|||
} catch (error) {
|
||||
toast.error(message(error));
|
||||
} finally {
|
||||
if (!noOriginal && (loading || 'fileContent' in previewData)) await loadOriginal();
|
||||
saving = false;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue