@@ -2215,16 +2215,24 @@ async def add_local_resources(self, application, entity_url, metadata, resources
22152215 "username" : "" ,
22162216 "password" : "" ,
22172217 }
2218- data = yaml .dump (docker_image_details )
2218+ data = yaml .dump (docker_image_details ). encode ( "utf-8" )
22192219 else :
22202220 p = Path (path )
2221- data = p .read_text () if p .exists () else ""
2221+ data = p .read_bytes () if p .exists () else b ""
22222222
22232223 self ._upload (data , path , application , name , resource_type , pending_id )
22242224
22252225 return resource_map
22262226
2227- def _upload (self , data , path , app_name , res_name , res_type , pending_id ):
2227+ def _upload (
2228+ self ,
2229+ data : bytes ,
2230+ path : str | Path ,
2231+ app_name : str ,
2232+ res_name : str ,
2233+ res_type : str ,
2234+ pending_id : str ,
2235+ ) -> None :
22282236 conn , headers , path_prefix = self .connection ().https_connection ()
22292237
22302238 query = f"?pendingid={ pending_id } "
@@ -2235,8 +2243,8 @@ def _upload(self, data, path, app_name, res_name, res_type, pending_id):
22352243 disp = f'form-data; filename="{ path } "'
22362244
22372245 headers ["Content-Type" ] = "application/octet-stream"
2238- headers ["Content-Length" ] = len (data )
2239- headers ["Content-Sha384" ] = hashlib .sha384 (bytes ( data , "utf-8" ) ).hexdigest ()
2246+ headers ["Content-Length" ] = str ( len (data ) )
2247+ headers ["Content-Sha384" ] = hashlib .sha384 (data ).hexdigest ()
22402248 headers ["Content-Disposition" ] = disp
22412249
22422250 conn .request ("PUT" , url , data , headers )
0 commit comments