diff --git a/google/cloud/storage/blob.py b/google/cloud/storage/blob.py index 6127411df..f1cb5666b 100644 --- a/google/cloud/storage/blob.py +++ b/google/cloud/storage/blob.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`` diff --git a/tests/system/test_system.py b/tests/system/test_system.py index 1ff17a61f..ec05b0c72 100644 --- a/tests/system/test_system.py +++ b/tests/system/test_system.py @@ -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"