@@ -494,6 +494,8 @@ def _CreateFileResponse_from_mldev(
494494 parent_object : dict = None ,
495495) -> dict :
496496 to_object = {}
497+ if getv (from_object , ['httpHeaders' ]) is not None :
498+ setv (to_object , ['http_headers' ], getv (from_object , ['httpHeaders' ]))
497499
498500 return to_object
499501
@@ -504,6 +506,8 @@ def _CreateFileResponse_from_vertex(
504506 parent_object : dict = None ,
505507) -> dict :
506508 to_object = {}
509+ if getv (from_object , ['httpHeaders' ]) is not None :
510+ setv (to_object , ['http_headers' ], getv (from_object , ['httpHeaders' ]))
507511
508512 return to_object
509513
@@ -840,7 +844,7 @@ def upload(
840844 'Unknown mime type: Could not determine the mimetype for your'
841845 ' file\n please set the `mime_type` argument'
842846 )
843- response = {}
847+
844848 if config_model and config_model .http_options :
845849 http_options = config_model .http_options
846850 else :
@@ -853,19 +857,20 @@ def upload(
853857 'X-Goog-Upload-Header-Content-Length' : f'{ file_obj .size_bytes } ' ,
854858 'X-Goog-Upload-Header-Content-Type' : f'{ file_obj .mime_type } ' ,
855859 },
856- 'deprecated_response_payload' : response ,
857860 }
858- self ._create (file = file_obj , config = {'http_options' : http_options })
861+ response = self ._create (
862+ file = file_obj , config = {'http_options' : http_options }
863+ )
859864
860865 if (
861- 'headers' not in response
862- or 'X-Goog-Upload-URL' not in response [ 'headers' ]
866+ response . http_headers is None
867+ or 'X-Goog-Upload-URL' not in response . http_headers
863868 ):
864869 raise KeyError (
865870 'Failed to create file. Upload URL did not returned from the create'
866871 ' file request.'
867872 )
868- upload_url = response [ 'headers' ] ['X-Goog-Upload-URL' ]
873+ upload_url = response . http_headers ['X-Goog-Upload-URL' ]
869874
870875 if isinstance (file , io .IOBase ):
871876 return_file = self ._api_client .upload_file (
@@ -1272,7 +1277,6 @@ async def upload(
12721277 ' file\n please set the `mime_type` argument'
12731278 )
12741279
1275- response = {}
12761280 if config_model and config_model .http_options :
12771281 http_options = config_model .http_options
12781282 else :
@@ -1285,18 +1289,20 @@ async def upload(
12851289 'X-Goog-Upload-Header-Content-Length' : f'{ file_obj .size_bytes } ' ,
12861290 'X-Goog-Upload-Header-Content-Type' : f'{ file_obj .mime_type } ' ,
12871291 },
1288- 'deprecated_response_payload' : response ,
12891292 }
1290- await self ._create (file = file_obj , config = {'http_options' : http_options })
1293+ response = await self ._create (
1294+ file = file_obj , config = {'http_options' : http_options }
1295+ )
1296+
12911297 if (
1292- 'headers' not in response
1293- or 'X-Goog-Upload-URL' not in response [ 'headers' ]
1298+ response . http_headers is None
1299+ or 'X-Goog-Upload-URL' not in response . http_headers
12941300 ):
12951301 raise KeyError (
12961302 'Failed to create file. Upload URL did not returned from the create'
12971303 ' file request.'
12981304 )
1299- upload_url = response [ 'headers' ] ['X-Goog-Upload-URL' ]
1305+ upload_url = response . http_headers ['X-Goog-Upload-URL' ]
13001306
13011307 if isinstance (file , io .IOBase ):
13021308 return_file = await self ._api_client .async_upload_file (
0 commit comments