From 26299270323ba08ddb2e4e1cbad948f7b4f44722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=90=E8=97=A4=E6=A0=84?= Date: Fri, 10 Apr 2026 11:26:40 +0800 Subject: [PATCH] fix(feishu): wrap image bytes in BytesIO before uploading to lark SDK --- gateway/platforms/feishu.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gateway/platforms/feishu.py b/gateway/platforms/feishu.py index a53dbab0d9..039874bccd 100644 --- a/gateway/platforms/feishu.py +++ b/gateway/platforms/feishu.py @@ -1580,13 +1580,18 @@ class FeishuAdapter(BasePlatformAdapter): return SendResult(success=False, error=f"Image file not found: {image_path}") try: - with open(image_path, "rb") as image_file: - body = self._build_image_upload_body( - image_type=_FEISHU_IMAGE_UPLOAD_TYPE, - image=image_file, - ) - request = self._build_image_upload_request(body) - upload_response = await asyncio.to_thread(self._client.im.v1.image.create, request) + import io as _io + with open(image_path, "rb") as f: + image_bytes = f.read() + # Wrap in BytesIO so lark SDK's MultipartEncoder can read .name and .tell() + image_file = _io.BytesIO(image_bytes) + image_file.name = os.path.basename(image_path) + body = self._build_image_upload_body( + image_type=_FEISHU_IMAGE_UPLOAD_TYPE, + image=image_file, + ) + request = self._build_image_upload_request(body) + upload_response = await asyncio.to_thread(self._client.im.v1.image.create, request) image_key = self._extract_response_field(upload_response, "image_key") if not image_key: return self._response_error_result(