fix: buffer upload path for feishu SDK (openclaw#10345) thanks @youngerstyle

Co-authored-by: zhiyi <7426274+youngerstyle@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
Tak Hoffman
2026-02-11 22:31:24 -06:00
parent 04e3a66f90
commit 8fdb2e64a7
+12 -10
View File
@@ -210,15 +210,16 @@ export async function uploadImageFeishu(params: {
const client = createFeishuClient(account); const client = createFeishuClient(account);
// SDK expects a Readable stream, not a Buffer // SDK accepts Buffer directly or fs.ReadStream for file paths
// Use type assertion since SDK actually accepts any Readable at runtime // Using Readable.from(buffer) causes issues with form-data library
const imageStream = typeof image === "string" ? fs.createReadStream(image) : Readable.from(image); // See: https://github.com/larksuite/node-sdk/issues/121
const imageData = typeof image === "string" ? fs.createReadStream(image) : image;
const response = await client.im.image.create({ const response = await client.im.image.create({
data: { data: {
image_type: imageType, image_type: imageType,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK stream type // eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK accepts Buffer or ReadStream
image: imageStream as any, image: imageData as any,
}, },
}); });
@@ -258,16 +259,17 @@ export async function uploadFileFeishu(params: {
const client = createFeishuClient(account); const client = createFeishuClient(account);
// SDK expects a Readable stream, not a Buffer // SDK accepts Buffer directly or fs.ReadStream for file paths
// Use type assertion since SDK actually accepts any Readable at runtime // Using Readable.from(buffer) causes issues with form-data library
const fileStream = typeof file === "string" ? fs.createReadStream(file) : Readable.from(file); // See: https://github.com/larksuite/node-sdk/issues/121
const fileData = typeof file === "string" ? fs.createReadStream(file) : file;
const response = await client.im.file.create({ const response = await client.im.file.create({
data: { data: {
file_type: fileType, file_type: fileType,
file_name: fileName, file_name: fileName,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK stream type // eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK accepts Buffer or ReadStream
file: fileStream as any, file: fileData as any,
...(duration !== undefined && { duration }), ...(duration !== undefined && { duration }),
}, },
}); });