Skip to content

Commit a107114

Browse files
docs: update storage guide
1 parent d79c929 commit a107114

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

docs/guide/storage.rst

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ Storage
44
The storage service allows you to upload files (eg. text, image,
55
video) to Firebase.
66

7+
.. code-block:: python
8+
9+
# Create storage instance
10+
storage = firebaseApp.storage()
11+
..
12+
13+
714
child
815
-----
916

@@ -13,6 +20,10 @@ with the Storage service.
1320
.. code-block:: python
1421
1522
storage.child("images/example.jpg")
23+
24+
# Alternative ways
25+
storage.child("images").child("example.jpg")
26+
storage.child("images", "example.jpg")
1627
..
1728
1829
put
@@ -23,9 +34,9 @@ token.
2334

2435
.. code-block:: python
2536
26-
storage = firebaseApp.storage()
2737
# as admin
2838
storage.child("images/example.jpg").put("example2.jpg")
39+
2940
# as user
3041
storage.child("images/example.jpg").put("example2.jpg", user['idToken'])
3142
..
@@ -38,7 +49,11 @@ name you want the downloaded file to have.
3849

3950
.. code-block:: python
4051
52+
# as admin
4153
storage.child("images/example.jpg").download("downloaded.jpg")
54+
55+
# as user
56+
storage.child("images/example.jpg").download("downloaded.jpg", user['idToken'])
4257
..
4358
4459
get_url
@@ -49,8 +64,17 @@ token which returns the storage url.
4964

5065
.. code-block:: python
5166
67+
# as admin
68+
storage.child("images/example.jpg").get_url()
69+
70+
# as admin with expiration time for link to expire
71+
storage.child("images/example.jpg").get_url(expiration_hour=12)
72+
73+
# as user
5274
storage.child("images/example.jpg").get_url(user["idToken"])
53-
# https://firebasestorage.googleapis.com/v0/b/storage-url.appspot.com/o/images%2Fexample.jpg?alt=media
75+
76+
# returned URL example:
77+
# https://firebasestorage.googleapis.com/v0/b/storage-url.appspot.com/o/images%2Fexample.jpg?alt=media&token=$token
5478
..
5579
5680
delete
@@ -61,5 +85,20 @@ token.
6185

6286
.. code-block:: python
6387
64-
storage.delete("images/example.jpg",user["idToken"])
88+
# as admin
89+
storage.child("images/example.jpg").delete()
90+
91+
# as user
92+
storage.child("images/example.jpg").delete(user["idToken"])
93+
..
94+
95+
list_of_files
96+
-------------
97+
98+
The list_of_files method works only if used under admin credentials.
99+
100+
.. code-block:: python
101+
102+
# as admin
103+
storage.list_of_files()
65104
..

0 commit comments

Comments
 (0)