This repository was archived by the owner on Nov 26, 2024. It is now read-only.
File tree 3 files changed +12
-6
lines changed
3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 1
- # Pyrebase [ ![ ] ( https://img.shields.io/pypi/v/Pyrebase.svg )] ( https://pypi.python.org/pypi/Pyrebase )
1
+ # Pyrebase
2
2
3
3
A simple python wrapper for the [ Firebase API] ( https://firebase.google.com ) .
4
4
Original file line number Diff line number Diff line change @@ -312,20 +312,26 @@ def child(self, *args):
312
312
self .path = new_path
313
313
return self
314
314
315
- def put (self , file_name , token = None ):
315
+ def put (self , file , token = None ):
316
316
# reset path
317
317
path = self .path
318
318
self .path = None
319
319
if token :
320
- file = open (file_name , 'rb' )
320
+ if isinstance (file , str ):
321
+ file_object = open (file , 'rb' )
322
+ else :
323
+ file_object = file
321
324
request_ref = self .storage_bucket + "/o?name={0}" .format (path )
322
325
headers = {"Authorization" : "Firebase " + token }
323
- request_object = self .requests .put (request_ref , headers = headers , data = file )
326
+ request_object = self .requests .put (request_ref , headers = headers , data = file_object )
324
327
raise_detailed_error (request_object )
325
328
return request_object .json ()
326
329
elif self .credentials :
327
330
blob = self .bucket .blob (path )
328
- return blob .upload_from_filename (filename = file_name )
331
+ if isinstance (file , str ):
332
+ return blob .upload_from_filename (filename = file )
333
+ else :
334
+ return blob .upload_from_file (file_obj = file )
329
335
330
336
def delete (self , name ):
331
337
self .bucket .delete_blob (name )
Original file line number Diff line number Diff line change 2
2
3
3
setup (
4
4
name = 'Pyrebase' ,
5
- version = '3.0.6 ' ,
5
+ version = '3.0.7 ' ,
6
6
url = 'https://github.com/thisbejim/Pyrebase' ,
7
7
description = 'A simple python wrapper for the Firebase API' ,
8
8
author = 'James Childs-Maidment' ,
You can’t perform that action at this time.
0 commit comments