Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Firebase如何检查Firebase存储上是否存在文件_Python_Firebase_Google Cloud Storage_Firebase Storage - Fatal编程技术网

Python Firebase如何检查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检查firebase存储上是否存在文件。这里有几种方法可以用于其他语言


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()
这意味着您不再需要“请求”模块