From ed846ebcfaf4d7950e944290cb8dede3c5b66489 Mon Sep 17 00:00:00 2001 From: Sebastien Flory Date: Tue, 10 Dec 2024 23:12:45 +0100 Subject: [PATCH] Fix: slack message filesize --- connectors/src/connectors/slack/bot.ts | 7 +++++-- front/lib/api/files/utils.ts | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/connectors/src/connectors/slack/bot.ts b/connectors/src/connectors/slack/bot.ts index 72390a210308..5d52ac28f30b 100644 --- a/connectors/src/connectors/slack/bot.ts +++ b/connectors/src/connectors/slack/bot.ts @@ -801,13 +801,16 @@ async function makeContentFragment( const contentType = "text/vnd.dust.attachment.slack.thread"; const fileName = `slack_thread-${channel.channel.name}-${threadTs}.txt`; + const blob = new Blob([section]); + const fileSize = blob.size; + const fileRes = await dustAPI.uploadFile({ contentType, fileName, - fileSize: section.length, + fileSize: fileSize, useCase: "conversation", useCaseMetadata: conversationId ? { conversationId } : undefined, - fileObject: new File([section], fileName, { type: contentType }), + fileObject: new File([blob], fileName, { type: contentType }), }); if (fileRes.isErr()) { diff --git a/front/lib/api/files/utils.ts b/front/lib/api/files/utils.ts index 039556977325..c7cf993c8e28 100644 --- a/front/lib/api/files/utils.ts +++ b/front/lib/api/files/utils.ts @@ -63,7 +63,8 @@ export const parseUploadRequest = async ( return new Err({ name: "dust_error", code: "file_too_large", - message: "File is too large.", + message: + "File is too large or the size passed to the File instance in the DB does not match the size of the uploaded file.", }); } // entire message: options.allowEmptyFiles is false, file size should be greater than 0