4
4
The storage service allows you to upload files (eg. text, image,
5
5
video) to Firebase.
6
6
7
+ .. code-block :: python
8
+
9
+ # Create storage instance
10
+ storage = firebaseApp.storage()
11
+ ..
12
+
13
+
7
14
child
8
15
-----
9
16
@@ -13,6 +20,10 @@ with the Storage service.
13
20
.. code-block :: python
14
21
15
22
storage.child(" images/example.jpg" )
23
+
24
+ # Alternative ways
25
+ storage.child(" images" ).child(" example.jpg" )
26
+ storage.child(" images" , " example.jpg" )
16
27
..
17
28
18
29
put
23
34
24
35
.. code-block :: python
25
36
26
- storage = firebaseApp.storage()
27
37
# as admin
28
38
storage.child(" images/example.jpg" ).put(" example2.jpg" )
39
+
29
40
# as user
30
41
storage.child(" images/example.jpg" ).put(" example2.jpg" , user[' idToken' ])
31
42
..
@@ -38,7 +49,11 @@ name you want the downloaded file to have.
38
49
39
50
.. code-block :: python
40
51
52
+ # as admin
41
53
storage.child(" images/example.jpg" ).download(" downloaded.jpg" )
54
+
55
+ # as user
56
+ storage.child(" images/example.jpg" ).download(" downloaded.jpg" , user[' idToken' ])
42
57
..
43
58
44
59
get_url
@@ -49,8 +64,17 @@ token which returns the storage url.
49
64
50
65
.. code-block :: python
51
66
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
52
74
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
54
78
..
55
79
56
80
delete
@@ -61,5 +85,20 @@ token.
61
85
62
86
.. code-block :: python
63
87
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()
65
104
..
0 commit comments