File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -804,7 +804,7 @@ def _extract_headers_from_download(self, response):
804804
805805 digests = {}
806806 for encoded_digest in x_goog_hash .split ("," ):
807- match = re .match (r"(crc32c|md5)=([\w\d]+)== " , encoded_digest )
807+ match = re .match (r"(crc32c|md5)=([\w\d/]+={0,3}) " , encoded_digest )
808808 if match :
809809 method , digest = match .groups ()
810810 digests [method ] = digest
Original file line number Diff line number Diff line change @@ -910,6 +910,18 @@ def test_upload_blob_owner(self):
910910 owner = same_blob .owner
911911 self .assertIn (user_email , owner ["entity" ])
912912
913+ def test_blob_crc32_md5_hash (self ):
914+ blob = self .bucket .blob ("MyBuffer" )
915+ file_contents = b"Hello World"
916+ blob .upload_from_string (file_contents )
917+ self .case_blobs_to_delete .append (blob )
918+
919+ download_blob = self .bucket .blob ("MyBuffer" )
920+
921+ self .assertEqual (download_blob .download_as_string (), file_contents )
922+ self .assertEqual (download_blob .crc32c , blob .crc32c )
923+ self .assertEqual (download_blob .md5_hash , blob .md5_hash )
924+
913925
914926class TestUnicode (unittest .TestCase ):
915927 @vpcsc_config .skip_if_inside_vpcsc
Original file line number Diff line number Diff line change @@ -1476,8 +1476,8 @@ def test_download_as_string_w_response_headers(self):
14761476 self .assertEqual (blob .content_encoding , "gzip" )
14771477 self .assertEqual (blob .cache_control , "max-age=1337;public" )
14781478 self .assertEqual (blob .storage_class , "STANDARD" )
1479- self .assertEqual (blob .md5_hash , "CS9tHYTtyFntzj7B9nkkJQ" )
1480- self .assertEqual (blob .crc32c , "4gcgLQ" )
1479+ self .assertEqual (blob .md5_hash , "CS9tHYTtyFntzj7B9nkkJQ== " )
1480+ self .assertEqual (blob .crc32c , "4gcgLQ== " )
14811481
14821482 def test_download_as_string_w_hash_response_header_none (self ):
14831483 blob_name = "blob-name"
You can’t perform that action at this time.
0 commit comments