mirror of
https://github.com/open-webui/open-webui
synced 2025-06-15 19:05:04 +00:00
refac: file upload handling behaviour
This commit is contained in:
parent
b80f0751f6
commit
32ea31144e
@ -125,37 +125,37 @@ def upload_file(
|
|||||||
)
|
)
|
||||||
if process:
|
if process:
|
||||||
try:
|
try:
|
||||||
|
if file.content_type:
|
||||||
|
if file.content_type.startswith(
|
||||||
|
(
|
||||||
|
"audio/mpeg",
|
||||||
|
"audio/wav",
|
||||||
|
"audio/ogg",
|
||||||
|
"audio/x-m4a",
|
||||||
|
"audio/webm",
|
||||||
|
"video/webm",
|
||||||
|
)
|
||||||
|
):
|
||||||
|
file_path = Storage.get_file(file_path)
|
||||||
|
result = transcribe(request, file_path)
|
||||||
|
|
||||||
if file.content_type.startswith(
|
process_file(
|
||||||
(
|
request,
|
||||||
"audio/mpeg",
|
ProcessFileForm(file_id=id, content=result.get("text", "")),
|
||||||
"audio/wav",
|
user=user,
|
||||||
"audio/ogg",
|
)
|
||||||
"audio/x-m4a",
|
elif file.content_type not in [
|
||||||
"audio/webm",
|
"image/png",
|
||||||
"video/webm",
|
"image/jpeg",
|
||||||
)
|
"image/gif",
|
||||||
):
|
"video/mp4",
|
||||||
file_path = Storage.get_file(file_path)
|
"video/ogg",
|
||||||
result = transcribe(request, file_path)
|
"video/quicktime",
|
||||||
|
]:
|
||||||
process_file(
|
process_file(request, ProcessFileForm(file_id=id), user=user)
|
||||||
request,
|
|
||||||
ProcessFileForm(file_id=id, content=result.get("text", "")),
|
|
||||||
user=user,
|
|
||||||
)
|
|
||||||
elif file.content_type not in [
|
|
||||||
"image/png",
|
|
||||||
"image/jpeg",
|
|
||||||
"image/gif",
|
|
||||||
"video/mp4",
|
|
||||||
"video/ogg",
|
|
||||||
"video/quicktime",
|
|
||||||
]:
|
|
||||||
process_file(request, ProcessFileForm(file_id=id), user=user)
|
|
||||||
else:
|
else:
|
||||||
log.info(
|
log.info(
|
||||||
f"File type {file.content_type} is not supported for processing, but trying to process anyway"
|
f"File type {file.content_type} is not provided, but trying to process anyway"
|
||||||
)
|
)
|
||||||
process_file(request, ProcessFileForm(file_id=id), user=user)
|
process_file(request, ProcessFileForm(file_id=id), user=user)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user