![](/img/trans.png)
[英]How to download file from firebase storage in python using firebase_admin
[英]Read JSON file from Firebase Storage using Admin SDK in Python without download
我正在通过 Python 成长,通过管理员 sdk 读取 Firebase 存储中存在的 JSON 文件。我已经阅读了以下问题
如何使用 firebase_admin 从 python 中的 firebase 存储下载文件
但在这种情况下,文件被下载到另一个文件。 是否可以在不下载和不公开的情况下阅读它? 或者是否可以制作一个临时文件,一旦 python 打印出来就删除它? 谢谢
我的代码:
import firebase_admin
from firebase_admin import credentials, storage
cred = credentials.Certificate('serviceAccount.json')
firebase_admin.initialize_app(cred, {
"storageBucket": "**.appspot.com"
})
source_blob_name = "UQ4ADY.json"
#The path to which the file should be downloaded
destination_file_name = r"temp\ftmp.json"
bucket = storage.bucket()
blob = bucket.blob(source_blob_name)
blob.download_to_filename(destination_file_name)
请注意,可能会有很多请求,这就是为什么我不想下载文件
在 Johm Hanley 发表评论后,我使用了download_as_text
函数:
import firebase_admin
from firebase_admin import credentials, storage
cred = credentials.Certificate('serviceAccount.json')
firebase_admin.initialize_app(cred, {
"storageBucket": "**.appspot.com"
})
source_blob_name = "UQ4ADY.json"
#The path to which the file should be downloaded
destination_file_name = r"temp\ftmp.json"
bucket = storage.bucket()
blob = bucket.blob(source_blob_name)
data = blob.download_as_text()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.