fix: extract correct MIME type from base64 profile images (#20171)
This commit is contained in:
@@ -306,12 +306,13 @@ async def get_model_profile_image(id: str, user=Depends(get_verified_user)):
|
||||
header, base64_data = model.meta.profile_image_url.split(",", 1)
|
||||
image_data = base64.b64decode(base64_data)
|
||||
image_buffer = io.BytesIO(image_data)
|
||||
media_type = header.split(";")[0].lstrip("data:")
|
||||
|
||||
return StreamingResponse(
|
||||
image_buffer,
|
||||
media_type="image/png",
|
||||
media_type=media_type,
|
||||
headers={
|
||||
"Content-Disposition": "inline; filename=image.png",
|
||||
"Content-Disposition": "inline",
|
||||
**cache_headers,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user