I'm trying to access the custom metadata on a file in Google cloud storage from within a Cloud Function, but it always returns "None".
The file definitely has custom metadata on it - the custom metadata can be seen from the GCS browser.
I can access the custom metadata successfully if I run my code in a cloud shell environment.
But if I run the same code in a cloud function, then the returned blob.metadata is always "None".
What am I doing wrong? What do I have to do differently in a Cloud Function compared to a Cloud Shell.
from google.cloud import storage
client = storage.Client()
bucket = client.bucket(<my bucket name>)
blob = bucket.get_blob(<my filename>)
metadata = blob.metadata
Note also that blob.download_as_string() gets me the file contents correctly - it's just the custom metadata I can't get.