2016-12-15 35 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

相關問題