@@ -144,12 +144,13 @@ def put_request(self, endpoint: str, body=None, files=None, data=None):
144
144
)
145
145
146
146
def upload_blob_s3 (
147
- self , endpoint : str , file_path : str , object_name : str , body = None
147
+ self , endpoint : str , file_path : str , object_name : str = None , body = None
148
148
):
149
149
"""Generic method to upload data to S3 storage and create the appropriate resource
150
150
in the backend.
151
151
"""
152
- presigned_json = self .get_request (endpoint )
152
+ params = {"storageInterface" : "s3" , "objectName" : object_name }
153
+ presigned_json = self .get_request (endpoint , params = params )
153
154
with open (file_path , "rb" ) as f :
154
155
with tqdm (
155
156
total = os .stat (file_path ).st_size ,
@@ -163,16 +164,19 @@ def upload_blob_s3(
163
164
presigned_json ["url" ], data = presigned_json ["fields" ], files = files
164
165
)
165
166
if res .ok :
166
- body ["storagePath" ] = f"s3:// { presigned_json [' storagePath' ] } "
167
+ body ["storagePath" ] = presigned_json [" storagePath" ]
167
168
return self .post_request (f"{ endpoint } /{ presigned_json ['id' ]} " , body = body )
168
169
else :
169
170
self ._raise_on_respose (res )
170
171
171
- def upload_blob_gcs (self , endpoint : str , file_path : str , body = None ):
172
+ def upload_blob_gcs (
173
+ self , endpoint : str , file_path : str , object_name : str = None , body = None
174
+ ):
172
175
"""Generic method to upload data to Google Cloud Storage and create the appropriate resource
173
176
in the backend.
174
177
"""
175
- presigned_json = self .get_request (endpoint )
178
+ params = {"storageInterface" : "gcs" , "objectName" : object_name }
179
+ presigned_json = self .get_request (endpoint , params = params )
176
180
with open (file_path , "rb" ) as f :
177
181
with tqdm (
178
182
total = os .stat (file_path ).st_size ,
@@ -187,6 +191,7 @@ def upload_blob_gcs(self, endpoint: str, file_path: str, body=None):
187
191
headers = {"Content-Type" : "application/x-gzip" },
188
192
)
189
193
if res .ok :
194
+ body ["storagePath" ] = presigned_json ["storagePath" ]
190
195
return self .post_request (f"{ endpoint } /{ presigned_json ['id' ]} " , body = body )
191
196
else :
192
197
self ._raise_on_respose (res )
0 commit comments