问题
I would like to set one of my storage buckets to automatically assign certain metadata to every item that is newly updated (disposition, attachment).
How do I do this, is there a way?
回答1:
As far as my knowledge goes there isn't a way to do that. I've been thinking on a workaround and I came up with a possible solution.
Use a Cloud Function that triggers when a file it's uploaded to a bucket [1], then POST to the API [2] [3] to edit the metadata of that file. This way, every file added to the bucket would have the same metadata (in the fields you want them to) without the need of change them manually.
In case you already have files in that bucket that need to have their metadata changed you can run this command found here [4]:
gsutil -m setmeta -h "[METADATA_KEY]:[METADATA_VALUE]" gs://[BUCKET_NAME]/*
来源:https://stackoverflow.com/questions/51812857/is-there-a-way-to-make-a-whole-google-storage-bucket-have-preset-metadata