mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-22 04:16:07 +00:00
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:
+5
-3
@@ -204,7 +204,9 @@ async def get_slack_image_to_base64(pic_url: str, bot_token: str):
|
|||||||
try:
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(pic_url, headers=headers) as resp:
|
async with session.get(pic_url, headers=headers) as resp:
|
||||||
image_data = await resp.read()
|
mime_type = resp.headers.get("Content-Type", "application/octet-stream")
|
||||||
return base64.b64encode(image_data).decode('utf-8')
|
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:
|
except Exception as e:
|
||||||
raise (e)
|
raise (e)
|
||||||
Reference in New Issue
Block a user