@@ -144,12 +144,13 @@ def put_request(self, endpoint: str, body=None, files=None, data=None):
144144 )
145145
146146 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
148148 ):
149149 """Generic method to upload data to S3 storage and create the appropriate resource
150150 in the backend.
151151 """
152- presigned_json = self .get_request (endpoint )
152+ params = {"storageInterface" : "s3" , "objectName" : object_name }
153+ presigned_json = self .get_request (endpoint , params = params )
153154 with open (file_path , "rb" ) as f :
154155 with tqdm (
155156 total = os .stat (file_path ).st_size ,
@@ -163,16 +164,19 @@ def upload_blob_s3(
163164 presigned_json ["url" ], data = presigned_json ["fields" ], files = files
164165 )
165166 if res .ok :
166- body ["storagePath" ] = f"s3:// { presigned_json [' storagePath' ] } "
167+ body ["storagePath" ] = presigned_json [" storagePath" ]
167168 return self .post_request (f"{ endpoint } /{ presigned_json ['id' ]} " , body = body )
168169 else :
169170 self ._raise_on_respose (res )
170171
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+ ):
172175 """Generic method to upload data to Google Cloud Storage and create the appropriate resource
173176 in the backend.
174177 """
175- presigned_json = self .get_request (endpoint )
178+ params = {"storageInterface" : "gcs" , "objectName" : object_name }
179+ presigned_json = self .get_request (endpoint , params = params )
176180 with open (file_path , "rb" ) as f :
177181 with tqdm (
178182 total = os .stat (file_path ).st_size ,
@@ -187,6 +191,7 @@ def upload_blob_gcs(self, endpoint: str, file_path: str, body=None):
187191 headers = {"Content-Type" : "application/x-gzip" },
188192 )
189193 if res .ok :
194+ body ["storagePath" ] = presigned_json ["storagePath" ]
190195 return self .post_request (f"{ endpoint } /{ presigned_json ['id' ]} " , body = body )
191196 else :
192197 self ._raise_on_respose (res )
0 commit comments