0

此代码虽然在某些地方可能效率低下,但会从存储中下载我的文件。不幸的是,它不会将它们下载到我想要它的特定文件夹,即提供的路径。有任何想法吗?

#call down and download all images from firebase
users_db = db.collection("users").stream()
for doc in users_db:
    if not os.path.exists(doc.id):
        os.makedirs(doc.id)
    username = doc.to_dict()["username"]
    cloud_path = f"identifiers/{doc.id}"
    new_file_name = f"{username}.jpg"
    current_path = f"{os.path.dirname(__file__)}/{doc.id}"
    print(f"Absolute path: {os.path.dirname(os.path.abspath(__file__))}\\{doc.id}".replace("\\", "/"))
    print(f"Path: {current_path}   File Name: {new_file_name}")
    storage.child(cloud_path).download(filename= new_file_name, path= f"{os.path.dirname(os.path.abspath(__file__))}\\{doc.id}\\{new_file_name}".replace("\\", "/"))

4

0 回答 0