- Notifications
You must be signed in to change notification settings - Fork 167
Closed
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- OS type and version: Debian Buster
- Python version: Python 3.7.3
- pip version: pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
google-cloud-storageversion: 1.35.1
Steps to reproduce
- Create a blob.
- Set
custom_time. - Upload the blob .
- Try to retrieve blob's
custom_time. - Expected result is a
datatime, but the actual result isNone.
If blob's custom_time is set before uploading, it is just lost. My understanding is that the metadata could be uploaded with the object's content at the same time without needing to patch it afterwards.
https://cloud.google.com/storage/docs/uploading-objects#rest-upload-objects
Code example
import datetime from google.cloud import storage bucket_name = "my-test-bucket" blob_name = "test_blob" client = storage.Client() bucket = client.get_bucket(bucket_name) blob = bucket.blob(blob_name) blob.custom_time = datetime.datetime.now(datetime.timezone.utc) print("Before upload {}".format(blob.custom_time)) blob.upload_from_string("test") blob.reload() print("After upload {}".format(blob.custom_time)) blob.custom_time = datetime.datetime.now(datetime.timezone.utc) blob.patch() blob.reload() print("After patching {}".format(blob.custom_time))Stack trace
Before upload 2021-02-05 10:24:08.405494+00:00 After upload None After patching 2021-02-05 10:24:08.814159+00:00 Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.