gpt4 book ai didi

python-3.x - 找到上传文件的url,firebase storage + python

转载 作者:行者123 更新时间:2023-12-04 15:39:05 26 4
gpt4 key购买 nike

我想知道如何从我上传到 firebase 存储的文件中获取 url?
这是我的代码:

    import firebase_admin
from firebase_admin import credentials, firestore, storage

cred=credentials.Certificate('/serviceAccountKey.json')
firebase_admin.initialize_app(cred, {
'storageBucket': <my_bucket_name>
})
db = firestore.client()

bucket = storage.bucket()
blob = bucket.blob('image.jpg')
blob.upload_from_filename('/image.jpg')

#here I'd like to have url of file I uploaded
print(blob.<url>)

提前致谢。

最佳答案

您应该使用以下代码:

blob.upload_from_filename(BLOB_PATH)
blob.make_public()
print(blob.public_url)

关于python-3.x - 找到上传文件的url,firebase storage + python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52451215/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com