Skip to content
Permalink
Browse files
fix: set custom_time on uploads (#374)
The custom_time property was incorrectly not included as a field
that could be set on object upload.

Fixes #372
  • Loading branch information
tritone committed Feb 8, 2021
1 parent 5c60d24 commit f048be10416f51cea4e6c8c5b805df7b5d9c4d32
Showing with 15 additions and 0 deletions.
  1. +2 −0 google/cloud/storage/blob.py
  2. +13 −0 tests/system/test_system.py
@@ -96,6 +96,7 @@
"contentLanguage",
_CONTENT_TYPE_FIELD,
"crc32c",
"customTime",
"md5Hash",
"metadata",
"name",
@@ -1530,6 +1531,7 @@ def _get_writable_metadata(self):
* ``contentLanguage``
* ``contentType``
* ``crc32c``
* ``customTime``
* ``md5Hash``
* ``metadata``
* ``name``
@@ -1027,6 +1027,19 @@ def test_upload_blob_owner(self):
owner = same_blob.owner
self.assertIn(user_email, owner["entity"])

def test_upload_blob_custom_time(self):
blob = self.bucket.blob("CustomTimeBlob")
file_contents = b"Hello World"
current_time = datetime.datetime.now()
blob.custom_time = current_time
blob.upload_from_string(file_contents)
self.case_blobs_to_delete.append(blob)

same_blob = self.bucket.blob("CustomTimeBlob")
same_blob.reload(projection="full")
custom_time = same_blob.custom_time.replace(tzinfo=None)
self.assertEqual(custom_time, current_time)

def test_blob_crc32_md5_hash(self):
blob = self.bucket.blob("MyBuffer")
file_contents = b"Hello World"

0 comments on commit f048be1

Please sign in to comment.