How to send already shared file to the channel ?
Description
I am trying to send a message with file using slack Java Bolt SDK. File X is already hosted and shared in channel C** via method files.upload. I am trying send this new message with slack file X using attachments parameter.
File attached to message after receiving it via files.info.
String fileId = "fileId";
String userToken = "token";
File file = slack.methods()
.filesInfo(requestBuilder -> requestBuilder
.token(userToken)
.file(fileId)
)
.getFile();
List<Attachment> attachments = List.of(Attachment.builder().files(List.of(file)).build());
Message message = slack.methods()
.chatPostMessage(requestBuilder -> requestBuilder
.token(userToken)
.channel("channelId")
.attachments(attachments)
.text("some message"))
.getMessage();
I am receiving message in slack, but message doesnt have file.
What i am missing or doing wrong. I guess i dont need to use files.upload, cause file is already shared in this channel.
What type of issue is this? (place an x in one of the [ ])
- [x] bug
- [ ] enhancement (feature request)
- [x] question
- [ ] documentation related
- [ ] example code related
- [ ] testing related
- [ ] discussion
Requirements (place an x in each of the [ ])
- [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
- [x] I've read and agree to the Code of Conduct.
- [x] I've searched for any related issues and avoided creating a duplicate issue.
Hi @tka4ukalex, thanks for writing in!
Instead of trying to manually crafting the file attachments, we recommend having the file's permalink (file.getPermalink()) in the text message. With that, Slack properly generates the file attachment for you.
I hope this was helpful to you.
👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.
As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.