Skip to content

Commit d03b14d

Browse files
committed
Send storagePath in model / dataset upload
1 parent fa18b0f commit d03b14d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

unboxapi/api.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def upload_blob_s3(self, endpoint: str, file_path: str, body=None):
161161
presigned_json["url"], data=presigned_json["fields"], files=files
162162
)
163163
if res.ok:
164+
body["storagePath"] = f"s3://{presigned_json['storagePath']}"
164165
return self.post_request(f"{endpoint}/{presigned_json['id']}", body=body)
165166
else:
166167
self._raise_on_respose(res)
@@ -193,11 +194,11 @@ def transfer_blob(self, endpoint: str, file_path: str, body=None):
193194
resource in the backend when using a local deployment.
194195
"""
195196
id = uuid.uuid4()
197+
blob_path = f"{UNBOX_STORAGE_PATH}/{endpoint}/{id}"
196198
try:
197-
os.makedirs(f"{UNBOX_STORAGE_PATH}/{endpoint}/{id}", exist_ok=True)
199+
os.makedirs(blob_path, exist_ok=True)
198200
except OSError as _:
199-
raise UnboxException(
200-
f"Directory {UNBOX_STORAGE_PATH}/{endpoint}/{id} cannot be created"
201-
)
202-
shutil.copyfile(file_path, f"{UNBOX_STORAGE_PATH}/{endpoint}/{id}/{id}")
201+
raise UnboxException(f"Directory {blob_path} cannot be created")
202+
shutil.copyfile(file_path, f"{blob_path}/{id}")
203+
body["storagePath"] = f"local://{blob_path}/{id}"
203204
return self.post_request(f"{endpoint}/{id}", body=body)

0 commit comments

Comments
 (0)