6

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

How to do this?

porton
  • 4,928
  • 10
  • 37
  • 76

1 Answers1

13

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,005
  • 2
  • 25
  • 39
  • 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/**/*.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