@@ -115,6 +115,17 @@ def blob_download_to_filename_chunked(client, _preconditions, **resources):
115115 assert stored_contents == data
116116
117117
118+ def blob_download_to_filename_range (client , _preconditions , ** resources ):
119+ bucket = resources .get ("bucket" )
120+ file , data = resources .get ("file_data" )
121+ blob = client .bucket (bucket .name ).blob (file .name )
122+ with tempfile .NamedTemporaryFile () as temp_f :
123+ blob .download_to_filename (temp_f .name , start = 1024 , end = 512 * 1024 )
124+ with open (temp_f .name , "r" ) as file_obj :
125+ stored_contents = file_obj .read ()
126+ assert stored_contents == data [1024 : 512 * 1024 + 1 ]
127+
128+
118129def client_download_blob_to_file (client , _preconditions , ** resources ):
119130 bucket = resources .get ("bucket" )
120131 file , data = resources .get ("file_data" )
@@ -748,6 +759,7 @@ def object_acl_clear(client, _preconditions, **resources):
748759 client_download_blob_to_file ,
749760 blob_download_to_filename ,
750761 blob_download_to_filename_chunked ,
762+ blob_download_to_filename_range ,
751763 blob_download_as_bytes ,
752764 blob_download_as_text ,
753765 blobreader_read ,
@@ -756,6 +768,7 @@ def object_acl_clear(client, _preconditions, **resources):
756768 client_download_blob_to_file ,
757769 blob_download_to_filename ,
758770 blob_download_to_filename_chunked ,
771+ blob_download_to_filename_range ,
759772 blob_download_as_bytes ,
760773 blob_download_as_text ,
761774 blobreader_read ,
0 commit comments