下载前如何检查Firebase中的文件类型? [英] How to check the type of file in Firebase before downloading?

查看:67
本文介绍了下载前如何检查Firebase中的文件类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从Firebase Storage下载一组图像.

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

在下载之前,我需要检查图像的类型(即,如果仅.jpeg,则仅需要下载).

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

有人可以在Python中帮助我吗?

Can anyone help me with a code in Python?

推荐答案

最简单的方法实际上是编写存储安全规则,除非文件的内容类型为image/*,否则该规则将禁止下载:

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/.*');
     }
   }
 }
}

在文档中查看更多 .

这篇关于下载前如何检查Firebase中的文件类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆