Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set custom_time on uploads #374

Merged
merged 1 commit into from Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions google/cloud/storage/blob.py
Expand Up @@ -96,6 +96,7 @@
"contentLanguage",
_CONTENT_TYPE_FIELD,
"crc32c",
"customTime",
"md5Hash",
"metadata",
"name",
Expand Down Expand Up @@ -1530,6 +1531,7 @@ def _get_writable_metadata(self):
* ``contentLanguage``
* ``contentType``
* ``crc32c``
* ``customTime``
* ``md5Hash``
* ``metadata``
* ``name``
Expand Down
13 changes: 13 additions & 0 deletions tests/system/test_system.py
Expand Up @@ -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"
Expand Down