How to check the type of file in Firebase before downloading?

730 views Asked by At

I need to download a set of images from Firebase Storage.

Before downloading, I need to check the type of Images (i.e. if .jpeg only, only then will I need to download).

Can anyone help me with a code in Python?

1

There are 1 answers

0
Mike McDonald On

The easiest way of doing this is actually writing a Storage Security Rule that disallows downloads unless the file has a content type of image/*:

service firebase.storage {
 match /b/<your-firebase-storage-bucket>/o {
   match /images/{imageId} {
       allow read: if resource.contentType.matches('image/.*');
     }
   }
 }
}

See more in the docs.