Set metadata for all objects in a Google Storage bucket
Asked Answered
A

1

7

I want to set Content-Type metadata to image/jpeg for all objects of a Google Storage bucket.

How to do this?

Akeylah answered 7/10, 2018 at 18:14 Comment(0)
N
16

Using gsutil and its setmeta command:

gsutil -m setmeta -h "Content-Type:image/jpeg" gs://YOUR_BUCKET/**/*.jpg

Use the -m to activate a parallel update, in case you have a lot of objects.

The /**/* pattern will perform a recursive search on any folders that you may have on your bucket.

Nutriment answered 7/10, 2018 at 20:35 Comment(2)
This only covers objects without forward slash characters in the name. If you also want to operate on objects named like picture/in/some/folder.jpg, then you should use a recursive glob pattern: gs://YOUR_BUCKET/**/*.jpgCalbert
Thanks @Calbert ! I'll add it to my answer.Nutriment

© 2022 - 2024 — McMap. All rights reserved.