[英]How do I download image from firebase storage folder with python?
I want to download image from firebase storage which the resouce folder我想从资源文件夹的 firebase 存储下载图像
can anyone teach me how to do?谁能教我怎么做?
my english is not good forgive me我的英语不好请原谅我
This code will help you download any image in Firebase, you will find in your local folder as "img.png"此代码将帮助您下载 Firebase 中的任何图像,您将在本地文件夹中找到“img.png”
The credentials.json should be in the same folder you run this code in and you can retrieve it from Firebase, its particular to your account credentials.json 应该在您运行此代码的同一文件夹中,您可以从 Firebase 中检索它,它特定于您的帐户
In my case my storage bucket is called 'aisparkdev-tinder.appspot.com'就我而言,我的存储桶称为“aisparkdev-tinder.appspot.com”
When generating the blob variable, the string is just the path to your image.生成 blob 变量时,字符串只是图像的路径。
import urllib
import firebase_admin
from firebase_admin import credentials
from firebase_admin import storage
cred = credentials.Certificate("credentials.json")
# Initialize the app with a service account, granting admin privileges
appF = firebase_admin.initialize_app(cred,
{'storageBucket': 'aisparkdev-tinder.appspot.com',},
name='storage')
bucket = storage.bucket(app=appF)
blob = bucket.blob("profileImages/"+profilePic+".jpg")
urllib.request.urlretrieve(blob.generate_signed_url(datetime.timedelta(seconds=300), method='GET'), ".\\img.png")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.