@@ -61,7 +61,7 @@ def upload_object(storage_client,
61
61
bucket = storage_client .get_bucket (bucket_name )
62
62
blob = bucket .blob (object_name )
63
63
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 )
65
65
66
66
67
67
def download_object (storage_client ,
@@ -92,17 +92,21 @@ def main(bucket, filename):
92
92
upload_object (storage_client , bucket , filename , filename , ENCRYPTION_KEY )
93
93
print ('Downloading it back' )
94
94
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 )
97
101
assert filecmp .cmp (filename , tmpfile .name ), \
98
102
'Downloaded file has different content from the original file.'
99
103
print ('Done' )
100
104
101
105
102
106
if __name__ == '__main__' :
103
107
parser = argparse .ArgumentParser (
104
- description = __doc__ ,
105
- formatter_class = argparse .RawDescriptionHelpFormatter )
108
+ description = __doc__ ,
109
+ formatter_class = argparse .RawDescriptionHelpFormatter )
106
110
parser .add_argument ('bucket' , help = 'Your Cloud Storage bucket.' )
107
111
parser .add_argument ('filename' , help = 'A file to upload and download.' )
108
112
0 commit comments