Is there a way to make a whole Google Storage Bucket have preset metadata?

天涯浪子 提交于 2021-01-27 18:41:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!