我每天都有一个CSV文件在Firebase存储桶中上演。我想每天将此更新的CSV文件下载到本地计算机上。
使用以下Python代码,我可以生成一个链接,单击该链接并下载文件。但是,我想知道是否可以下载它而无需单击生成的链接。
import datetime
import firebase_admin
from firebase_admin import credentials
from firebase_admin import storage
### Fetch the service account key JSON file contents
cred = credentials.Certificate("SDK_key.json")
### Initialize the app with a service account, granting admin privileges
app = firebase_admin.initialize_app(cred, {'storageBucket': 'XYZ.appspot.com',}, name='storage')
bucket = storage.bucket(app=app)
### Address of file to downloaded
blob = bucket.blob("test.csv")
### Generate a link and clicking on the link downloads the file
print(blob.generate_signed_url(datetime.timedelta(seconds=300), method='GET'))
答案 0 :(得分:0)
我想您会找到答案here。
@James Daniels指出getSignedURL()
是检索指定文件的关键组件,但是您可以使用Firebase Admin SDK(充当Google的Cloud Storage SDK的包装器)来实现。