Skip to content

Commit 72630a9

Browse files
committed
feat: allow passing files using pathlib
1 parent 6fbaa2a commit 72630a9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/sasctl/_services/files.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# SPDX-License-Identifier: Apache-2.0
66

77
import os
8+
from pathlib import Path
89

910
from sasctl.utils.cli import sasctl_command
1011

@@ -40,7 +41,7 @@ def create_file(cls, file, folder=None, filename=None, expiration=None):
4041
4142
Parameters
4243
----------
43-
file : str or file_like
44+
file : str, pathlib.Path, or file_like
4445
Path to the file to upload or a file-like object.
4546
folder : str or dict, optional
4647
Name, or, or folder information as returned by :func:`.get_folder`.
@@ -55,8 +56,10 @@ def create_file(cls, file, folder=None, filename=None, expiration=None):
5556
A dictionary containing the file attributes.
5657
5758
"""
58-
if isinstance(file, str):
59-
filename = filename or os.path.splitext(os.path.split(file)[1])[0]
59+
if isinstance(file, (str, Path)):
60+
# file = str(file)
61+
# filename = filename or os.path.splitext(os.path.split(file)[1])[0]
62+
filename = Path(file).name
6063

6164
with open(file, "rb") as f:
6265
file = f.read()

0 commit comments

Comments
 (0)