Search code examples
google-cloud-storagemime-typescontent-type

How to change the metadata of all specific file of exist objects in Google Cloud Storage?


I have uploaded thousands of files to google storage, and i found out all the files miss content-type,so that my website cannot get it right.

i wonder if i can set some kind of policy like changing all the files content-type at the same time, for example, i have bunch of .html files inside the bucket

a/b/index.html
a/c/a.html
a/c/a/b.html
a/a.html
.
.
.

is that possible to set the content-type of all the .html files with one command in the different place?


Solution

  • You could do:

    gsutil -m setmeta -h Content-Type:text/html gs://your-bucket/**.html