我想從資源檔案夾的 firebase 存盤下載影像

誰能教我怎么做?
我的英語不好請原諒我
uj5u.com熱心網友回復:
此代碼將幫助您下載 Firebase 中的任何影像,您將在本地檔案夾中找到“img.png”
credentials.json 應該在您運行此代碼的同一檔案夾中,您可以從 Firebase 中檢索它,它特定于您的帳戶
就我而言,我的存盤桶稱為“aisparkdev-tinder.appspot.com”
生成 blob 變數時,字串只是影像的路徑。
import urllib
import firebase_admin
from firebase_admin import credentials
from firebase_admin import storage
cred = credentials.Certificate("credentials.json")
# Initialize the app with a service account, granting admin privileges
appF = firebase_admin.initialize_app(cred,
{'storageBucket': 'aisparkdev-tinder.appspot.com',},
name='storage')
bucket = storage.bucket(app=appF)
blob = bucket.blob("profileImages/" profilePic ".jpg")
urllib.request.urlretrieve(blob.generate_signed_url(datetime.timedelta(seconds=300), method='GET'), ".\\img.png")
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/359424.html
