GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: extract hashes correctly during download (#238) · googleapis/python-storage@23cfb65

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
Filter options
  • google/cloud/storage
    • blob.py
  • tests
    • system
      • test_system.py
    • unit
      • test_blob.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎google/cloud/storage/blob.py‎

Copy file name to clipboardExpand all lines: google/cloud/storage/blob.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
Collapse file

‎tests/system/test_system.py‎

Copy file name to clipboardExpand all lines: tests/system/test_system.py
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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

914926
class TestUnicode(unittest.TestCase):
915927
@vpcsc_config.skip_if_inside_vpcsc
Collapse file

‎tests/unit/test_blob.py‎

Copy file name to clipboardExpand all lines: tests/unit/test_blob.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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"

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.