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

Fix #1342 files_upload_v2 fails to share files in a channel #1343

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration_tests/samples/basic_usage/uploading_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion slack_sdk/web/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion slack_sdk/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the cause of the issue

initial_comment=initial_comment,
thread_ts=thread_ts,
token=kwargs.get("token"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While fixing the issue, I've noticed that this one is missing here. With this, developers can pass "token" to v2 method to overwrite the token given when initializing WebClient. Current code does not response the parameter for this specific API call. That was a different bug.

**kwargs,
)
if request_file_info is True:
Expand Down
3 changes: 2 additions & 1 deletion slack_sdk/web/legacy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down