open-webui/backend/open_webui/utils/files.py

22 lines
627 B
Python
Raw Normal View History

2025-09-23 14:40:59 +08:00
from open_webui.routers.images import (
load_b64_image_data,
upload_image,
)
def get_image_url_from_base64(request, base64_image_string, metadata, user):
if "data:image/png;base64" in base64_image_string:
image_url = ""
# Extract base64 image data from the line
image_data, content_type = load_b64_image_data(base64_image_string)
if image_data is not None:
image_url = upload_image(
request,
image_data,
content_type,
metadata,
user,
)
return image_url
return None