[GH-ISSUE #410] Setting blob.custom_time doesn't work, returns always None #79

Closed
opened 2026-03-03 12:08:05 +03:00 by kerem · 7 comments
Owner

Originally created by @oittaa on GitHub (Feb 4, 2021).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/410

I have a piece of code like the following:

self.client = storage.Client()
self.bucket = self.client.get_bucket(bucket_name)

blob = self.bucket.blob(blob_name)
blob.upload_from_string(value, content_type=content_type)
blob.reload()
blob.custom_time = datetime.datetime.now(datetime.timezone.utc)
blob.patch()

If I set custom_time before uploading, even the real Google server erases it from the blob. That's why I patch it after the upload. The fake server unfortunately loses it even after patch.

blob = self.bucket.get_blob(blob_name)
print(blob.custom_time)

results in None

Originally created by @oittaa on GitHub (Feb 4, 2021). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/410 I have a piece of code like the following: ``` self.client = storage.Client() self.bucket = self.client.get_bucket(bucket_name) blob = self.bucket.blob(blob_name) blob.upload_from_string(value, content_type=content_type) blob.reload() blob.custom_time = datetime.datetime.now(datetime.timezone.utc) blob.patch() ``` If I set `custom_time` before uploading, even the real Google server erases it from the blob. That's why I patch it after the upload. The fake server unfortunately loses it even after `patch`. ``` blob = self.bucket.get_blob(blob_name) print(blob.custom_time) ``` results in `None`
kerem 2026-03-03 12:08:05 +03:00
Author
Owner
<!-- gh-comment-id:773746133 --> @oittaa commented on GitHub (Feb 5, 2021): To me it looks like the `Custom-Time` is completely missing from objects. https://github.com/fsouza/fake-gcs-server/blob/297b8cdcd2f8fac8652f8b20c023ececb1c368b1/fakestorage/object.go#L25-L43 https://cloud.google.com/storage/docs/metadata#custom-time https://pkg.go.dev/cloud.google.com/go/storage#ObjectAttrsToUpdate
Author
Owner

@oittaa commented on GitHub (Feb 6, 2021):

The original Google Cloud issue about missing custom_time before patching is tracked here. https://github.com/googleapis/python-storage/issues/372

<!-- gh-comment-id:774517455 --> @oittaa commented on GitHub (Feb 6, 2021): The original Google Cloud issue about missing `custom_time` before patching is tracked here. https://github.com/googleapis/python-storage/issues/372
Author
Owner

@fsouza commented on GitHub (Feb 15, 2021):

Thanks for reporting and linking the docs!

<!-- gh-comment-id:779480395 --> @fsouza commented on GitHub (Feb 15, 2021): Thanks for reporting and linking the docs!
Author
Owner

@mar-pan commented on GitHub (Dec 23, 2022):

Hello @fsouza is there any chance that this could be assigned to someone and resolved? It looks like that Google resolved issue on their side and I can confirm that it works with "real" API

<!-- gh-comment-id:1363722471 --> @mar-pan commented on GitHub (Dec 23, 2022): Hello @fsouza is there any chance that this could be assigned to someone and resolved? It looks like that Google resolved issue on their side and I can confirm that it works with "real" API
Author
Owner

@fsouza commented on GitHub (Dec 28, 2022):

I opened #1024 (big round-number!) as a draft, in case someone wants to work on it. It's unlikely I'll be able to pick it back up in the next couple of weeks.

<!-- gh-comment-id:1366964994 --> @fsouza commented on GitHub (Dec 28, 2022): I opened #1024 (big round-number!) as a draft, in case someone wants to work on it. It's unlikely I'll be able to pick it back up in the next couple of weeks.
Author
Owner

@RachitSharma2001 commented on GitHub (Jan 7, 2023):

@fsouza I believe I have a solution that fixes this issue and updates CustomTime correctly. I am ready to submit a pr but since my solution is based off the changes I made to this PR (specifically the changes added to PatchObject method in object.go) I just want to make sure that those changes are good before submitting a pr to fix this issue.

<!-- gh-comment-id:1374620056 --> @RachitSharma2001 commented on GitHub (Jan 7, 2023): @fsouza I believe I have a solution that fixes this issue and updates `CustomTime` correctly. I am ready to submit a pr but since my solution is based off the changes I made to [this](https://github.com/fsouza/fake-gcs-server/pull/1016) PR (specifically the changes added to `PatchObject` method in `object.go`) I just want to make sure that those changes are good before submitting a pr to fix this issue.
Author
Owner

@fsouza commented on GitHub (Jan 7, 2023):

@RachitSharma2001 hey, I'm going to look at your PR later today (in 2 hours or so). If you prefer, you can open another PR on top of that one, or we can wait.

Apologies for the delayed review.

<!-- gh-comment-id:1374620758 --> @fsouza commented on GitHub (Jan 7, 2023): @RachitSharma2001 hey, I'm going to look at your PR later today (in 2 hours or so). If you prefer, you can open another PR on top of that one, or we can wait. Apologies for the delayed review.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#79
No description provided.