File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -579,22 +579,25 @@ def get_image(self, image_id):
579579 image = self .make_request ('GET' , 'image/%s' % image_id )
580580 return Image (image )
581581
582+ def upload_from_base64 (self , encoded_string , config = None , anon = True ):
583+ return self .upload (encoded_string , config , anon )
584+
582585 def upload_from_path (self , path , config = None , anon = True ):
583586 with open (path , 'rb' ) as fd :
584- self .upload (fd , config , anon )
587+ contents = fd .read ()
588+ b64 = base64 .b64encode (contents )
589+ return self .upload (b64 , config , anon )
585590
586591 def upload (self , fd , config = None , anon = True ):
587592 if not config :
588593 config = dict ()
589594
590- contents = fd .read ()
591- b64 = base64 .b64encode (contents )
592595 data = {
593- 'image' : b64 ,
596+ 'image' : fd ,
594597 'type' : 'base64' ,
595598 }
596599 data .update ({meta : config [meta ] for meta in set (self .allowed_image_fields ).intersection (config .keys ())})
597-
600+
598601 return self .make_request ('POST' , 'upload' , data , anon )
599602
600603 def upload_from_url (self , url , config = None , anon = True ):
You can’t perform that action at this time.
0 commit comments