Skip to content

Commit 6d0dc4a

Browse files
Support pathlike objects in upload util
Also switch to inbuilt filename encode helper, since it accepts paths
1 parent d6c206a commit 6d0dc4a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

slack_sdk/web/internal_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ def _to_v2_file_upload_item(upload_file: Dict[str, Any]) -> Dict[str, Optional[A
317317
content = upload_file.get("content")
318318
data: Optional[bytes] = None
319319
if file is not None:
320-
if isinstance(file, str): # filepath
321-
with open(file.encode("utf-8", "ignore"), "rb") as readable:
320+
if isinstance(file, (str, os.PathLike)): # filepath
321+
with open(os.fsencode(file), "rb") as readable:
322322
data = readable.read()
323323
elif isinstance(file, bytes):
324324
data = file

0 commit comments

Comments
 (0)