fix: correctly set the file content type for images, webp, jepg, png
This commit is contained in:
parent
840bea79e8
commit
ff70bbdcec
@ -945,12 +945,22 @@ async def handle_upload(prompt_id: str, data, key: str, content_type_key: str, d
|
|||||||
# # Skipping temp files
|
# # Skipping temp files
|
||||||
if item.get("type") == "temp":
|
if item.get("type") == "temp":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
file_type = item.get(content_type_key, default_content_type)
|
||||||
|
file_extension = os.path.splitext(item.get("filename"))[1]
|
||||||
|
if file_extension in ['.jpg', '.jpeg']:
|
||||||
|
file_type = 'image/jpeg'
|
||||||
|
elif file_extension == '.png':
|
||||||
|
file_type = 'image/png'
|
||||||
|
elif file_extension == '.webp':
|
||||||
|
file_type = 'image/webp'
|
||||||
|
|
||||||
await upload_file(
|
await upload_file(
|
||||||
prompt_id,
|
prompt_id,
|
||||||
item.get("filename"),
|
item.get("filename"),
|
||||||
subfolder=item.get("subfolder"),
|
subfolder=item.get("subfolder"),
|
||||||
type=item.get("type"),
|
type=item.get("type"),
|
||||||
content_type=item.get(content_type_key, default_content_type)
|
content_type=file_type
|
||||||
)
|
)
|
||||||
|
|
||||||
# Upload files in the background
|
# Upload files in the background
|
||||||
|
Loading…
x
Reference in New Issue
Block a user