Unable to set blob metadata
See original GitHub issueI am trying to set custom metadata on a blob. However, this does not work. I’m using the following script:
#!/usr/bin/env python3
import os
from gcloud import storage
client = storage.Client('super secret id')
bucket = client.get_bucket('super secret bucket')
blob = bucket.blob('kirby.png')
blob.metadata = dict(Color='Pink')
with open(os.path.expanduser('~/Pictures/kirby.png'), 'rb') as img_data:
blob.upload_from_file(img_data)
When retrieving the blob or inspecing it in the developer console, the metadata is still unset.
Issue Analytics
- State:
- Created 8 years ago
- Comments:22 (11 by maintainers)
Top Results From Across the Web
AzureBlob: Unable to set blob metadata (x-ms-meta-* headers ...
It is currently impossible to set blob metadata when calling commit_block_list(). The _commit_block_list_options() method does not pass the ...
Read more >c# - Can't set Azure Block Blob Metadata on upload time
I can't setup metadata on the upload time. If I call await blockBlob.SetMetadataAsync(); before UploadFromStreamAsync() , I get error: Microsoft ...
Read more >Set Blob Metadata (REST API) - Azure Storage | Microsoft Learn
The Set Blob Metadata operation sets user-defined metadata for the specified blob as one or more name-value pairs.
Read more >Metadata Load for Microsoft Azure Blob Storage fails with ...
Metadata Load for Microsoft Azure Blob Storage fails and the following is from the stdout.log. ... at java.lang.Thread.run(Thread.java:748) Caused by: javax.net.
Read more >Setting and Retrieving Azure Blob Storage Properties and ...
Explore how to manage blob properties and metadata using the Azure Portal and ... You'll notice that these properties can't be modified, which...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think this is a duplicate of #754. The use of metadata is a bit ambiguous as metadata refers to both the metadata of an object (such as Cache-Control) and the
metadataproperty, meant for custom metadata.Anyway, to the issue. Any update? The problem with
patchis that the object is online briefly with wrong metadata, or less briefly in case of a connection failure between two requests. And, it increasesmetageneration.You can work around this bug by creating a completely new dictionary, assigning it to blob.metadata, and doing blob.patch():
Your blob will now have the {‘mynewproperty’:‘awesome’} metadata property in its stored metadata list on GCS.