mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-12 22:47:04 +08:00
fix:editing image upload function
This commit is contained in:
parent
0aff1685cb
commit
84d6daf397
20
server.py
20
server.py
@ -199,10 +199,18 @@ class PromptServer():
|
|||||||
upload_dir, image_upload_type = get_dir_by_type(image_upload_type)
|
upload_dir, image_upload_type = get_dir_by_type(image_upload_type)
|
||||||
print(f"Upload directory: {upload_dir}, Image type: {image_upload_type}, Overwrite: {overwrite}")
|
print(f"Upload directory: {upload_dir}, Image type: {image_upload_type}, Overwrite: {overwrite}")
|
||||||
|
|
||||||
if image and image.get("file"):
|
if image:
|
||||||
filename = image.get("filename")
|
if isinstance(image, web.FileField):
|
||||||
file_content = image.get("file")
|
filename = image.filename
|
||||||
|
file_content = await image.read()
|
||||||
|
else:
|
||||||
|
filename = image.get("filename")
|
||||||
|
file_content = image.get("file")
|
||||||
|
if is_base64_string(file_content):
|
||||||
|
file_content = base64.b64decode(file_content.split(",")[1])
|
||||||
|
|
||||||
print(f"Filename: {filename}")
|
print(f"Filename: {filename}")
|
||||||
|
print(f"File content length: {len(file_content)}")
|
||||||
|
|
||||||
if not filename or not file_content:
|
if not filename or not file_content:
|
||||||
print("No filename or file content provided")
|
print("No filename or file content provided")
|
||||||
@ -273,17 +281,19 @@ class PromptServer():
|
|||||||
content_type = request.headers.get('Content-Type')
|
content_type = request.headers.get('Content-Type')
|
||||||
print(f"Content-Type: {content_type}")
|
print(f"Content-Type: {content_type}")
|
||||||
|
|
||||||
|
post = {}
|
||||||
if 'application/json' in content_type:
|
if 'application/json' in content_type:
|
||||||
try:
|
try:
|
||||||
post = await request.json()
|
post = await request.json()
|
||||||
# print(f"Received JSON post data: {post}")
|
print(f"Received JSON post data: {post}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error parsing JSON: {e}")
|
print(f"Error parsing JSON: {e}")
|
||||||
return web.Response(status=400, text="Invalid JSON data")
|
return web.Response(status=400, text="Invalid JSON data")
|
||||||
elif 'multipart/form-data' in content_type:
|
elif 'multipart/form-data' in content_type:
|
||||||
try:
|
try:
|
||||||
post = await request.post()
|
post = await request.post()
|
||||||
# print(f"Received form-data post data: {post}")
|
print(f"Received form-data post data: {post}")
|
||||||
|
post = {key: post[key] for key in post.keys()}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error parsing form-data: {e}")
|
print(f"Error parsing form-data: {e}")
|
||||||
return web.Response(status=400, text="Invalid form-data")
|
return web.Response(status=400, text="Invalid form-data")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user