'Can I list objects in my GCS Bucket by contentType? Or by suffix/file name?

I have a GCS Storage bucket that is very large (tens of millions of objects). Over the past year or so there have been a handful of files that were uploaded with the incorrect MIME/content type, and those files were not processed correctly due to the incorrect type.

I would like to identify those files so they can be re-uploaded with the correct contentType so they can be processed correctly.

There are two ways that I think they could be identified without simply listing all objects in the bucket (due to cost of listing all objects):

  1. List objects by content type. I know what the content type of the incorrect files will be, so if I could just perform something like WHERE contentType then I could easily get the files

  2. Luckily, all the incorrect files will have the exact same file name. So if I could list files that have a "suffix" (as opposed to the supported prefix query) then I could get all those files.

Anyone have any ideas? If neither of these solutions are supported I guess I will have to list all the files in the bucket and spend hundreds of dollars.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source