@@ -61,7 +61,7 @@ def upload_object(storage_client,
6161 bucket = storage_client .get_bucket (bucket_name )
6262 blob = bucket .blob (object_name )
6363 with open (filename , 'rb' ) as f :
64- blob .upload_from_file (f , encryption_key = encryption_key )
64+ blob .upload_from_file (f , encryption_key = encryption_key )
6565
6666
6767def download_object (storage_client ,
@@ -92,17 +92,21 @@ def main(bucket, filename):
9292 upload_object (storage_client , bucket , filename , filename , ENCRYPTION_KEY )
9393 print ('Downloading it back' )
9494 with tempfile .NamedTemporaryFile (mode = 'w+b' ) as tmpfile :
95- download_object (storage_client , bucket , object_name = filename ,
96- filename = tmpfile .name , encryption_key = ENCRYPTION_KEY )
95+ download_object (
96+ storage_client ,
97+ bucket ,
98+ object_name = filename ,
99+ filename = tmpfile .name ,
100+ encryption_key = ENCRYPTION_KEY )
97101 assert filecmp .cmp (filename , tmpfile .name ), \
98102 'Downloaded file has different content from the original file.'
99103 print ('Done' )
100104
101105
102106if __name__ == '__main__' :
103107 parser = argparse .ArgumentParser (
104- description = __doc__ ,
105- formatter_class = argparse .RawDescriptionHelpFormatter )
108+ description = __doc__ ,
109+ formatter_class = argparse .RawDescriptionHelpFormatter )
106110 parser .add_argument ('bucket' , help = 'Your Cloud Storage bucket.' )
107111 parser .add_argument ('filename' , help = 'A file to upload and download.' )
108112
0 commit comments