From fe3fd664af7a9352e82ec2be75183e11647675d3 Mon Sep 17 00:00:00 2001 From: Guanchao Wang Date: Fri, 6 Jun 2025 10:04:00 +0800 Subject: [PATCH] Fix/slack image (#1501) * fix: dingtalk adapters couldn't handle images * fix: slack adapter couldn't put the image in logger --- pkg/utils/image.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/utils/image.py b/pkg/utils/image.py index 86230df8..f69d29d2 100644 --- a/pkg/utils/image.py +++ b/pkg/utils/image.py @@ -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) \ No newline at end of file