@@ -165,7 +165,7 @@ def delete(self, name, token):
165
165
166
166
raise_detailed_error (request_object )
167
167
168
- def download (self , path , filename , token = None ):
168
+ def download (self , filename , token = None ):
169
169
""" Download file from storage.
170
170
171
171
| For more details:
@@ -179,9 +179,6 @@ def download(self, path, filename, token=None):
179
179
https://firebase.google.com/docs/storage/web/download-files#download_data_via_url
180
180
181
181
182
- :type path: str
183
- :param path: Path to cloud file
184
-
185
182
:type filename: str
186
183
:param filename: File name to be downloaded as.
187
184
@@ -190,28 +187,31 @@ def download(self, path, filename, token=None):
190
187
to :data:`None`.
191
188
"""
192
189
193
- # remove leading backlash
194
- url = self .get_url (token )
190
+ if self .credentials :
195
191
196
- if path .startswith ('/' ):
197
- path = path [1 :]
192
+ # reset path
193
+ path = self .path
194
+ self .path = None
195
+
196
+ # remove leading backlash
197
+ if path .startswith ('/' ):
198
+ path = path [1 :]
198
199
199
- if self .credentials :
200
200
blob = self .bucket .get_blob (path )
201
- if not blob is None :
201
+ if blob is not None :
202
202
blob .download_to_filename (filename )
203
203
204
204
elif token :
205
205
headers = {"Authorization" : "Firebase " + token }
206
- r = requests .get (url , stream = True , headers = headers )
206
+ r = requests .get (self . get_url ( token ) , stream = True , headers = headers )
207
207
208
208
if r .status_code == 200 :
209
209
with open (filename , 'wb' ) as f :
210
210
for chunk in r :
211
211
f .write (chunk )
212
212
213
213
else :
214
- r = requests .get (url , stream = True )
214
+ r = requests .get (self . get_url ( token ) , stream = True )
215
215
216
216
if r .status_code == 200 :
217
217
with open (filename , 'wb' ) as f :
0 commit comments