7

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

How to do this?

porton
  • 5,214
  • 11
  • 47
  • 95

1 Answers1

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.

Mangu
  • 3,160
  • 2
  • 25
  • 42
  • 3
    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/**/*.jpg` – mhouglum Oct 08 '18 at 16:03
  • 1
    Thanks @mhouglum ! I'll add it to my answer. – Mangu Oct 08 '18 at 16:42