Skip to content

Commit 4b0016b

Browse files
committed
feat: handle file-like or raw bytes
1 parent 3953dd2 commit 4b0016b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sasctl/_services/model_repository.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def import_model_from_zip(
524524
project : str or dict
525525
The name or id of the model project, or a dictionary
526526
representation of the project.
527-
file : bytes
527+
file : bytes or file-like object
528528
The ZIP file containing the model and contents.
529529
description : str
530530
The description of the model.
@@ -551,9 +551,14 @@ def import_model_from_zip(
551551
}
552552
params = "&".join("{}={}".format(k, v) for k, v in params.items())
553553

554+
if not isinstance(file, bytes):
555+
if file.seekable():
556+
file.seek(0)
557+
file = file.read()
558+
554559
r = cls.post(
555560
"/models#octetStream",
556-
data=file.read(),
561+
data=file,
557562
params=params,
558563
headers={"Content-Type": "application/octet-stream"},
559564
)

0 commit comments

Comments
 (0)