[GH-ISSUE #273] Patch call with new content-type does nothing #57

Closed
opened 2026-03-03 12:07:52 +03:00 by kerem · 1 comment
Owner

Originally created by @ex-nerd on GitHub (Jun 18, 2020).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/273

As far as I can see in the fake-gcs-server code, contentType is only set when the object is created, and can't be updated.

I'm using the official python gcs library, basically as follows:

# init
from google.cloud import storage
client = BigMessyConnectionToFakeGcsServer(storage.Client)
bucket = client.bucket("my-test-bucket")
key = "test-key"

# upload some data
blob = bucket.blob(key)
blob.upload_from_string(b"some data", content_type="application/octet-stream")

# now fix the content type
blob = bucket.get_blob(key)
blob.content_type = "text/plain"
blob.patch()

The content-type value returned from the API request (buried in google's patch() method definition) is the original unchanged application/octet-stream, as is the content-type when trying to download the blob.

Debugging into google's code, this is sending {"contentType": "application/some-new-type"} along with the API request as the body content, which seems to be completely ignored by Server.patchObject unmarshaling into its metadata struct.

Originally created by @ex-nerd on GitHub (Jun 18, 2020). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/273 As far as I can see in the fake-gcs-server code, contentType is only set when the object is created, and can't be updated. I'm using the official python gcs library, basically as follows: ```python # init from google.cloud import storage client = BigMessyConnectionToFakeGcsServer(storage.Client) bucket = client.bucket("my-test-bucket") key = "test-key" # upload some data blob = bucket.blob(key) blob.upload_from_string(b"some data", content_type="application/octet-stream") # now fix the content type blob = bucket.get_blob(key) blob.content_type = "text/plain" blob.patch() ``` The content-type value returned from the API request (buried in google's `patch()` method definition) is the original unchanged `application/octet-stream`, as is the content-type when trying to download the blob. Debugging into google's code, this is sending `{"contentType": "application/some-new-type"}` along with the API request as the body content, which seems to be completely ignored by `Server.patchObject` unmarshaling into its `metadata` struct.
kerem 2026-03-03 12:07:52 +03:00
Author
Owner

@corytheboyd-smartsheet commented on GitHub (Oct 13, 2023):

FWIW I think I just ran into this same issue. Wrote the integration test for our feature that updates an object's content-type, and was confused about what I was doing wrong with what I though was a very simple implementation 😅

<!-- gh-comment-id:1762228547 --> @corytheboyd-smartsheet commented on GitHub (Oct 13, 2023): FWIW I think I just ran into this same issue. Wrote the integration test for our feature that updates an object's content-type, and was confused about what I was doing wrong with what I though was a very simple implementation 😅
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#57
No description provided.