Open matthewdwood82 opened 3 years ago
No problem.
That is a sticky question. It depends on if the channel is private.
if not you can query the list of files in a channel and get back the url to download.
here is the relevant api docs page
Thanks for the prompt reply. All the channels I'm interested in are public. To make sure I have this right, to get a list of those URLs I'd do something like slack_files(method = 'files.list', ...)
and then I can pass URLs in the resulting list to something like Base R download.file()
?
Thanks again, -Matt
@matthewdwood82 I'm sorry that we never replied to this! I suspect we went off to sort it out and got lost in some weeds. I happen to be back in those weeds today, so I'm typing out an answer to this even if it's long past something you care about!
The short answer: No, you can't just download.file. You'll need to authenticate in order to download the files.
The longish answer: Huh. It looks to me like we need to effectively implement these as special endpoints. Or at least it'd be nice to do so! It'll be something along these lines:
res <- httr::GET(
url = URL_FROM_files.list,
config = httr::add_headers(Authorization = paste("Bearer", Sys.getenv("SLACK_API_TOKEN")))
)
file <- httr::content(res)
I suspect what we'll really want to do is explicitly set as = "raw"
in that content()
call, and then writeBin()
that raw object. I'll need to read when I implement this (which is now on my to-do list), though, and probably experiment a little to figure it out.
Hi,
Not really an issue, but was not sure how else to ask. I see in slackcalls it looks like you can upload a file to a space using files_slack() . Is there a way to download a file from slack with this or a similar method?
Thanks, -Matt