Package pyrobase :: Package webservice :: Module imgur :: Class ImgurUploader
[hide private]
[frames] | no frames]

Class ImgurUploader

source code


Upload an image to "imgur.com".

Sample code:

   imgur = ImgurUploader()
   image = imgur.upload("favicon.jpg")
   # OR: image = imgur.upload(open("favicon.jpg", "rb"))
   # OR: image = imgur.upload(open("favicon.jpg", "rb").read())
   # OR: image = imgur.upload("http://i.imgur.com/5EuUx.jpg")
   print image.links.original
Instance Methods [hide private]
 
__init__(self, api_key=None, mock_http=False)
Initialize upload parameters.
source code
 
upload(self, image, name=None)
Upload the given image, which can be a http[s] URL, a path to an existing file, binary image data, or an open file handle.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  UPLOAD_URL = 'http://api.imgur.com/2/upload.json'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, api_key=None, mock_http=False)
(Constructor)

source code 

Initialize upload parameters.

Parameters:
  • api_key - the API key (optionally taken from IMGUR_APIKEY environment variable).
Overrides: object.__init__