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

custom metadata is not stored when a new object is uploaded #288

Open
CNDW opened this issue Sep 16, 2024 · 0 comments
Open

custom metadata is not stored when a new object is uploaded #288

CNDW opened this issue Sep 16, 2024 · 0 comments

Comments

@CNDW
Copy link

CNDW commented Sep 16, 2024

Describe the bug
New objects being created via the google.cloud.storage.Blob api that have had metadata set on the object via blob.metadata are not having the metadata persisted in the emulator.

To Reproduce
The following code snippet will fail when run against the emulator but work when run against GCS

from google.cloud.storage import Client
from tempfile import NamedTemporaryFile

client = Client()
bucket = client.create_bucket("testbucket")
blob = bucket.blob("test.txt")
blob.metadata = {"foo": "bar"}

with NamedTemporaryFile() as file:
    file.write("file-content")
    file.flush()
    file.seek(0)
    blob.upload_from_file(file)
    
uploaded_blob = bucket.get_blob("test.txt")
assert uploaded_blob.metadata == {"foo": "bar"}

Expected behavior
Any attached metadata should persist on the file saved in the emulator

System (please complete the following information):

  • OS version: latest gcp-storage-emulator docker image
  • Python version: 3.12
  • gcp-storage-emulator version: v2024.08.03

Additional context
I have a proposed fix in the following PR
#287

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant