Skip to content

Commit f4e5f47

Browse files
dblockts-3156Copilot
committed
Set a default filename so that Slack displays the file preview correctly
Fixes files_upload not showing image previews when filename is not specified, since multipart-post falls back to the local IO path as the filename, which Slack treats as a binary file. Co-authored-by: ts-3156 <ts_3156@yahoo.co.jp> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b9c2822 commit f4e5f47

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
### 3.2.1 (Next)
22

3+
* [#375](https://github.com/slack-ruby/slack-ruby-client/pull/375): Set a default filename in `files_upload` so Slack displays image previews correctly when none is specified - [@ts-3156](https://github.com/ts-3156), [@dblock](https://github.com/dblock).
4+
35
* [#591](https://github.com/slack-ruby/slack-ruby-client/pull/591): Generate AI CHANGELOG entries and PR summaries for automated API update PRs, lock simplecov below 1.1.0 to avoid breaking Coveralls - [@dblock](https://github.com/dblock).
46
* [#590](https://github.com/slack-ruby/slack-ruby-client/pull/590): Add entity.acknowledgeCommentAction and entity.presentComments methods - [@slack-ruby-ci-bot](https://github.com/apps/slack-ruby-ci-bot).
57
* [#590](https://github.com/slack-ruby/slack-ruby-client/pull/590): Add admin.apps.mcpServers, admin.apps.mcpServers.permissions, and admin.apps.permissions endpoints - [@slack-ruby-ci-bot](https://github.com/apps/slack-ruby-ci-bot).

‎lib/slack/web/api/endpoints/files.rb‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def files_sharedPublicURL(options = {})
192192
# @see https://api.slack.com/methods/files.upload
193193
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/files/files.upload.json
194194
def files_upload(options = {})
195+
options = options.merge(filename: 'file') if options[:file] && !options[:filename]
195196
post('files.upload', options)
196197
end
197198
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/lib/slack/web/api/endpoints/files.rb b/lib/slack/web/api/endpoints/files.rb
2+
index 13a1889..9ce4894 100644
3+
--- a/lib/slack/web/api/endpoints/files.rb
4+
+++ b/lib/slack/web/api/endpoints/files.rb
5+
@@ -192,6 +192,7 @@ module Slack
6+
# @see https://api.slack.com/methods/files.upload
7+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/files/files.upload.json
8+
def files_upload(options = {})
9+
+ options = options.merge(filename: 'file') if options[:file] && !options[:filename]
10+
post('files.upload', options)
11+
end
12+
end

0 commit comments

Comments
 (0)