From 7b27a4d7b25eaa73fd23f3b68f1ed5eec76fe5a1 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Tue, 7 Mar 2023 15:17:47 +0900 Subject: [PATCH] Fix #1342 files_upload_v2 fails to share files in a channel --- integration_tests/samples/basic_usage/uploading_files.py | 1 + slack_sdk/web/async_client.py | 3 ++- slack_sdk/web/client.py | 3 ++- slack_sdk/web/legacy_client.py | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/integration_tests/samples/basic_usage/uploading_files.py b/integration_tests/samples/basic_usage/uploading_files.py index 6a93d9c33..7d0c828a5 100644 --- a/integration_tests/samples/basic_usage/uploading_files.py +++ b/integration_tests/samples/basic_usage/uploading_files.py @@ -14,3 +14,4 @@ channels = ",".join(["#random"]) filepath = "./tmp.txt" response = client.files_upload(channels=channels, file=filepath) +response = client.files_upload_v2(channel=response.get("file").get("channels")[0], file=filepath) diff --git a/slack_sdk/web/async_client.py b/slack_sdk/web/async_client.py index d20c57cce..870827b8f 100644 --- a/slack_sdk/web/async_client.py +++ b/slack_sdk/web/async_client.py @@ -3152,9 +3152,10 @@ async def files_upload_v2( channel_to_share = channels[0] completion = await self.files_completeUploadExternal( files=[{"id": f["file_id"], "title": f["title"]} for f in files], - channel=channel_to_share, + channel_id=channel_to_share, initial_comment=initial_comment, thread_ts=thread_ts, + token=kwargs.get("token"), **kwargs, ) if request_file_info is True: diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py index f1963e4a9..ce0f0f7f1 100644 --- a/slack_sdk/web/client.py +++ b/slack_sdk/web/client.py @@ -3143,9 +3143,10 @@ def files_upload_v2( channel_to_share = channels[0] completion = self.files_completeUploadExternal( files=[{"id": f["file_id"], "title": f["title"]} for f in files], - channel=channel_to_share, + channel_id=channel_to_share, initial_comment=initial_comment, thread_ts=thread_ts, + token=kwargs.get("token"), **kwargs, ) if request_file_info is True: diff --git a/slack_sdk/web/legacy_client.py b/slack_sdk/web/legacy_client.py index 6895946a9..62d322662 100644 --- a/slack_sdk/web/legacy_client.py +++ b/slack_sdk/web/legacy_client.py @@ -3154,9 +3154,10 @@ def files_upload_v2( channel_to_share = channels[0] completion = self.files_completeUploadExternal( files=[{"id": f["file_id"], "title": f["title"]} for f in files], - channel=channel_to_share, + channel_id=channel_to_share, initial_comment=initial_comment, thread_ts=thread_ts, + token=kwargs.get("token"), **kwargs, ) if request_file_info is True: