Skip to content

Commit

Permalink
feat: handle file-like or raw bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
jlwalke2 committed Aug 14, 2024
1 parent 3953dd2 commit 4b0016b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/sasctl/_services/model_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def import_model_from_zip(
project : str or dict
The name or id of the model project, or a dictionary
representation of the project.
file : bytes
file : bytes or file-like object
The ZIP file containing the model and contents.
description : str
The description of the model.
Expand All @@ -551,9 +551,14 @@ def import_model_from_zip(
}
params = "&".join("{}={}".format(k, v) for k, v in params.items())

if not isinstance(file, bytes):
if file.seekable():
file.seek(0)
file = file.read()

r = cls.post(
"/models#octetStream",
data=file.read(),
data=file,
params=params,
headers={"Content-Type": "application/octet-stream"},
)
Expand Down

0 comments on commit 4b0016b

Please sign in to comment.