Fix/slack image (#1501)

* fix: dingtalk adapters couldn't handle images

* fix: slack adapter couldn't put the image in logger
This commit is contained in:
Guanchao Wang
2025-06-06 10:04:00 +08:00
committed by GitHub
parent 6402755ac6
commit fe3fd664af

View File

@@ -204,7 +204,9 @@ async def get_slack_image_to_base64(pic_url: str, bot_token: str):
try:
async with aiohttp.ClientSession() as session:
async with session.get(pic_url, headers=headers) as resp:
image_data = await resp.read()
return base64.b64encode(image_data).decode('utf-8')
mime_type = resp.headers.get("Content-Type", "application/octet-stream")
file_bytes = await resp.read()
base64_str = base64.b64encode(file_bytes).decode("utf-8")
return f"data:{mime_type};base64,{base64_str}"
except Exception as e:
raise (e)
raise (e)