0

I am trying to figure a way to send a file to a user from my app.

slack documentation briefly mentions "uploading files directly to Slack is preferred" here https://api.slack.com/messaging/files/remote#:~:text=Remote%20files%20are%20files%20not,an%20easy%20button%20for%20files.

but they don't link to actually using those uploaded files. When I upload a file as a user, it shows up unfurled:

sent as a user

I am trying to figure a way to send a file in a message to a user from an app, so that it shows up like that. Any recommendations are really appreciated.

Alexei Masterov
  • 382
  • 2
  • 10
  • 2
    Does this answer your question? [How to upload files to slack using file.upload and requests](https://stackoverflow.com/questions/43464873/how-to-upload-files-to-slack-using-file-upload-and-requests) – MattieTK May 31 '21 at 23:25
  • partially. What I don't know how to do, is how to avoid re-uploading the same file multiple times (i.e. upload once, and then send it it to each user without having to re-upload) – Alexei Masterov Jun 02 '21 at 13:30
  • You won't be able to do that without storing in your application a list of files you have uploaded and their `ts` IDs in order to reference them in new messages – MattieTK Jun 02 '21 at 20:38
  • I don't mind doing that. How do I send a file using it's TS ID? – Alexei Masterov Jun 03 '21 at 21:58
  • So you wouldn't be sending the file, you'd be sending a message that references the previous file as an attachment. You'd have to make sure that the channel has access to the file before attaching it. This is a good example of how you might do that https://stackoverflow.com/a/64111536/3707940 – MattieTK Jun 04 '21 at 13:55
  • Thanks for trying to help. That link doesn’t help though, unfortunately. Could you please send a line of code that send user a message with file given a file id. (I know about sending a permalink, that’s not what I am looking for) I want the message to look as if I uploaded the file – Alexei Masterov Jun 05 '21 at 16:03

0 Answers0