You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use pyrebase to download a file from firebase storage. This file is located in customers/BoomMZrVfrOOOYa4JVibOJQoroT2/example.txt, I'm using this code to download it:
This works when I allow read and write to anyone from firebase storage. I'm using these firebase storage rules:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /customers/{userId}/{allPaths=**} {
allow read: if request.auth.uid == userId;
}
}
}
This only allows users to download files from a folder named with their user ID. The problem is that i cannot downloaded files from firebase storage if it requires authentication in my rules. If authentication is not required, then my code works.
The text was updated successfully, but these errors were encountered:
nosec2
changed the title
How to include UID inside of storage.child to download files
How to authenticate request for storage.child to download files
Aug 24, 2022
@nosec2 , Pyrebase does not support what you're looking for. However firebase-rest-api available in PyPI, which I recently started maintaining, supports it.
I am trying to use pyrebase to download a file from firebase storage. This file is located in customers/BoomMZrVfrOOOYa4JVibOJQoroT2/example.txt, I'm using this code to download it:
UID = 'BoomMZrVfrOOOYa4JVibOJQoroT2'
path_on_cloud = f"customers/{UID}/example.txt"
storage.child(path_on_cloud).download("C:\Users\username\Desktop\test\k.txt")
This works when I allow read and write to anyone from firebase storage. I'm using these firebase storage rules:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /customers/{userId}/{allPaths=**} {
allow read: if request.auth.uid == userId;
}
}
}
This only allows users to download files from a folder named with their user ID. The problem is that i cannot downloaded files from firebase storage if it requires authentication in my rules. If authentication is not required, then my code works.
The text was updated successfully, but these errors were encountered: