Skip to content
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

files_upload does nothing #479

Open
andres-haku opened this issue Jun 8, 2023 · 1 comment
Open

files_upload does nothing #479

andres-haku opened this issue Jun 8, 2023 · 1 comment
Labels

Comments

@andres-haku
Copy link

andres-haku commented Jun 8, 2023

I have tried the chat_postMessage method, and it works perfectly. However, when using the file_uploads method, it returns an OK status but doesn't post anything in my Slack channel.

Then tried with curl and successfully posted my file in the Slack channel.

What am I doing wrong? Why does it work with chat_postMessage but does not with the file_uploads method? I have to assume that my config, token, app permissions, etc. Is working properly. Otherwise, I wouldn't be able to post text messages with chat_postMessage.

I followed the docs as much as possible and took a quick look at the endpoints/files.rb file of this gem and I can't seem to find where I'm falling short.

# Gemfile

gem 'slack-ruby-client', '~> 0.11.1'
gem 'faraday', '0.9.0'
slack_message_params = {
  channel: '#andres-test',
  as_user: true,
  file: Faraday::UploadIO.new("#{tmp_path}/test.txt", 'text/plain'),
  filename: 'test.txt',
  title: 'test',
  initial_comment: 'Attached test file'
}
        
@client.file_uploads(slack_message_params) # => OK status, but doesn't post anything
curl -F file=@/path/to/file -F "initial_comment=test" -F channels=andres-test -H "Authorization: Bearer xoxb-my-token" https://slack.com/api/files.upload

# works!
@dblock
Copy link
Collaborator

dblock commented Jun 8, 2023

I assume file_uploads is just a typo? The correct name is files_upload.

The next problem I see is channel. The API requires channels, and takes a comma-separated list. Try changing that?

We should add patches that ensure that "either a file or content parameter" are provided (from the documentation), and add support for channel (singular), and channels (array of strings), so that the caller can mix and match. PRs welcome!

@dblock dblock added the bug? label Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants