2016-12-15 52 views
1

我需要从Firebase存储下载一组图像。如何在下载之前检查Firebase中的文件类型?

下载之前,我需要检查图像的类型(即如果.jpeg只,那么我需要下载)。

任何人都可以用Python中的代码来帮助我吗?

+0

没有用于Firebase存储的Python API。您可以使用适用于Python的gcloud API:https://cloud.google.com/storage/docs/xml-api/gspythonlibrary –

回答

0

这样做的最简单的方法其实就是写一个存储安全规则,禁止下载,除非该文件有image/*内容类型:

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

查看更多in the docs

相关问题