Python Firebase如何检查Firebase存储上是否存在文件
您好,我想知道是否可以使用python检查firebase存储上是否存在文件。这里有几种方法可以用于其他语言Python Firebase如何检查Firebase存储上是否存在文件,python,firebase,google-cloud-storage,firebase-storage,Python,Firebase,Google Cloud Storage,Firebase Storage,您好,我想知道是否可以使用python检查firebase存储上是否存在文件。这里有几种方法可以用于其他语言 python的等效方法是什么。我能够使用请求模块和文件的公共url使其工作。希望这能帮助其他面临同样问题的人 import requests from firebase_admin import storage #Creates the blob reference to file on the server bucket = storage.bucket() blob = bu
python的等效方法是什么。我能够使用请求模块和文件的公共url使其工作。希望这能帮助其他面临同样问题的人
import requests
from firebase_admin import storage
#Creates the blob reference to file on the server
bucket = storage.bucket()
blob = bucket.blob("firebase/path/to/file")
#Requests the file using the public url
r = requests.head(blob.public_url)
#Whether the file exists or not on the server
fileExists = (r.status_code == requests.codes.ok)
编辑
多亏了一些你可以使用的有用的指针
fileExists = blob.exists()
这意味着您不再需要“请求”模块