node.jsuploadslackbolt

Uploading file to slack using `uploadV2` only partially uploads the file


I'm uploading files to slack via the node.js Bolt SDK. However, only the first 66kb of the file gets uploaded to slack. This is fine for small text documents, but not useful for images etc. Here is the code I've used:

async function uploadFileToSlack(filepath, slackApp, channelId, threadId) {

    const fileInfo = {
        file: fs.createReadStream(filepath),
        filename: filepath,
        initial_comment: filepath,
        thread_ts: threadId,
        channel_id: channelId
    };
    console.debug(`uploading file ${filepath}....`);
    const uploadResult = await slackApp.client.files.uploadV2(fileInfo);
    console.log('upload complete.');
}

Any ideas to look into? As far as I can see Slack only has an upload limit of 1GB per file, so I don't think the files I'm uploading are too big (a few MB at best).


Solution

  • Sorry for this confusion! Our team is aware of this issue: https://github.com/slackapi/node-slack-sdk/issues/1601 It will be improved in the next release within a few business days.