Skip to content

Commit 0c21814

Browse files
use filename for uploaded files (#1774)
Co-authored-by: Ashley <[email protected]>
1 parent c84c1af commit 0c21814

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,4 @@ helpful and collaborative way.
302302
[slack-community]: https://slackcommunity.com/
303303
[files_upload_v2]: https://github.com/slackapi/python-slack-sdk/releases/tag/v3.19.0
304304
[aiohttp]: https://aiohttp.readthedocs.io/
305+

slack_sdk/web/internal_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,11 @@ def _to_v2_file_upload_item(upload_file: Dict[str, Any]) -> Dict[str, Optional[A
345345
if filename is None:
346346
# use the local filename if filename is missing
347347
if isinstance(file, (str, os.PathLike)):
348-
filename = os.fspath(file).split(os.path.sep)[-1]
348+
filename = os.path.basename(os.fspath(file))
349349
else:
350350
filename = "Uploaded file"
351351

352-
title = upload_file.get("title", "Uploaded file")
352+
title = upload_file.get("title")
353353
if data is None:
354354
raise SlackRequestError(f"File content not found for filename: {filename}, title: {title}")
355355

0 commit comments

Comments
 (0)