-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What sort of Stream is fileUploadV2
looking for?
#2131
Comments
Hey @cssinate 👋 Thanks for sharing this setup and question! 🎁 I'm moving this issue to the slackapi/node-slack-sdk since this is related to file uploads using
A blob of binary data can sometimes be caused by unexpected data mixing with an unknown filetype and misleading file extension - meaning this confusion is super fair! I believe the upload and readable stream are working as expected, but the data downloaded from const readableStream = await fetch(fileInfo.file.url_private, {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.SLACK_TOKEN}`,
},
}).then((r) => {
if (!r.body) {
throw new Error('Response body is null');
}
return Readable.from(r.body);
}); This seems to download (then upload) a file uploaded by a user as long as the bot has been added to that channel and includes the I apologize for the delay in this response, but I hope this change downloads the files as expected. Please let me know if something else seems strange though 🙏 |
Thanks so much! This worked. I have a quick follow-up request for confirmation... It seems that, even if a file is public across the workspace, a bot can't just re-share/forward that file to a DM. Is that accurate? The only way to send files in DMs is to always use the upload method and create new copies of the same file? |
If you include the file's URL in a DM message, you can share the file again without uploading it again. If the file is visible to the recipient, Slack's UI should display the file preview. |
(Filling out the following with as much detail as you can provide will help us answer your question sooner.)
@slack/bolt
version4.1.1
Your
App
and Receiver ConfigurationNode.js runtime version
20.13.1
Steps to reproduce:
I'm trying to create a bot to help run a hackathon; all of the pitching, team management, swag forms, and demo submissions, etc. I want teams to be able to upload a video into their private team channel, and when voting opens, the bot posts all of the videos in a public channel simultaneously. I'm having trouble doing that. Here's a minimal test with an MP4 file I uploaded.
The
file
says it can accept a Stream, but when it posts this in the DM, it's a 56KB Binary file presented to the user. Visiting the filePath in a browser shows the MP4 as expected.I fully recognize this could be a lack of understanding on my part with Readable Streams. I apologize if that's the sole issue at play.
Expected result:
I expect the readableStream passed into
file
to be given back in the same file format and size as the input file.Actual result:
The file came back as a binary file.
Requirements
For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
The text was updated successfully, but these errors were encountered: