This repository was archived by the owner on Mar 31, 2026. It is now read-only.
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: google/cloud/storage/blob.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -804,7 +804,7 @@ def _extract_headers_from_download(self, response): |
804 | 804 |
|
805 | 805 | digests = {} |
806 | 806 | 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) |
808 | 808 | if match: |
809 | 809 | method, digest = match.groups() |
810 | 810 | digests[method] = digest |
|
Collapse file
Copy file name to clipboardExpand all lines: tests/system/test_system.py +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -910,6 +910,18 @@ def test_upload_blob_owner(self): |
910 | 910 | owner = same_blob.owner |
911 | 911 | self.assertIn(user_email, owner["entity"]) |
912 | 912 |
|
| 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 | + |
913 | 925 |
|
914 | 926 | class TestUnicode(unittest.TestCase): |
915 | 927 | @vpcsc_config.skip_if_inside_vpcsc |
|
Collapse file
Copy file name to clipboardExpand all lines: tests/unit/test_blob.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1476,8 +1476,8 @@ def test_download_as_string_w_response_headers(self): |
1476 | 1476 | self.assertEqual(blob.content_encoding, "gzip") |
1477 | 1477 | self.assertEqual(blob.cache_control, "max-age=1337;public") |
1478 | 1478 | 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==") |
1481 | 1481 |
|
1482 | 1482 | def test_download_as_string_w_hash_response_header_none(self): |
1483 | 1483 | blob_name = "blob-name" |
|