16
16
HTTPException ,
17
17
Request ,
18
18
UploadFile ,
19
- BackgroundTasks ,
20
19
)
21
20
22
21
from open_webui .config import CACHE_DIR
23
22
from open_webui .constants import ERROR_MESSAGES
24
23
from open_webui .env import ENABLE_FORWARD_USER_INFO_HEADERS , SRC_LOG_LEVELS
25
- from open_webui .routers .files import upload_file
24
+ from open_webui .routers .files import upload_file_handler
26
25
from open_webui .utils .auth import get_admin_user , get_verified_user
27
26
from open_webui .utils .images .comfyui import (
28
27
ComfyUIGenerateImageForm ,
@@ -468,7 +467,7 @@ def load_url_image_data(url, headers=None):
468
467
return None
469
468
470
469
471
- def upload_image (request , background_tasks , image_data , content_type , metadata , user ):
470
+ def upload_image (request , image_data , content_type , metadata , user ):
472
471
image_format = mimetypes .guess_extension (content_type )
473
472
file = UploadFile (
474
473
file = io .BytesIO (image_data ),
@@ -477,9 +476,8 @@ def upload_image(request, background_tasks, image_data, content_type, metadata,
477
476
"content-type" : content_type ,
478
477
},
479
478
)
480
- file_item = upload_file (
479
+ file_item = upload_file_handler (
481
480
request ,
482
- background_tasks ,
483
481
file = file ,
484
482
metadata = metadata ,
485
483
process = False ,
@@ -492,7 +490,6 @@ def upload_image(request, background_tasks, image_data, content_type, metadata,
492
490
@router .post ("/generations" )
493
491
async def image_generations (
494
492
request : Request ,
495
- background_tasks : BackgroundTasks ,
496
493
form_data : GenerateImageForm ,
497
494
user = Depends (get_verified_user ),
498
495
):
@@ -566,9 +563,7 @@ async def image_generations(
566
563
else :
567
564
image_data , content_type = load_b64_image_data (image ["b64_json" ])
568
565
569
- url = upload_image (
570
- request , background_tasks , image_data , content_type , data , user
571
- )
566
+ url = upload_image (request , image_data , content_type , data , user )
572
567
images .append ({"url" : url })
573
568
return images
574
569
@@ -602,9 +597,7 @@ async def image_generations(
602
597
image_data , content_type = load_b64_image_data (
603
598
image ["bytesBase64Encoded" ]
604
599
)
605
- url = upload_image (
606
- request , background_tasks , image_data , content_type , data , user
607
- )
600
+ url = upload_image (request , image_data , content_type , data , user )
608
601
images .append ({"url" : url })
609
602
610
603
return images
@@ -655,7 +648,6 @@ async def image_generations(
655
648
image_data , content_type = load_url_image_data (image ["url" ], headers )
656
649
url = upload_image (
657
650
request ,
658
- background_tasks ,
659
651
image_data ,
660
652
content_type ,
661
653
form_data .model_dump (exclude_none = True ),
@@ -709,7 +701,6 @@ async def image_generations(
709
701
image_data , content_type = load_b64_image_data (image )
710
702
url = upload_image (
711
703
request ,
712
- background_tasks ,
713
704
image_data ,
714
705
content_type ,
715
706
{** data , "info" : res ["info" ]},
0 commit comments