@@ -0,0 +1,2415 @@
+%0Aimport base64%0Aimport os%0Aimport tempfile%0A%0Afrom django.core.exceptions import SuspiciousFileOperation%0Afrom django.core.files import File%0Afrom django.utils._os import safe_join%0Aimport requests%0A%0Afrom django.core.files.storage import Storage%0Afrom imgurpython import ImgurClient%0A%0Aclass ImgurStorage(Storage):%0A    %22%22%22%0A    Uses the Imgur cloud service to store images.%0A    Great for Heroku%0A    %0A    This is just a gist, needs some work.%0A    %22%22%22%0A    client_id = %22LOL%22%0A    client_secret = %22LOL%22%0A    access_token = %22LOL%22%0A    refresh_token = %22LOL%22%0A%0A    def upload(self, path):%0A        return self.client.upload_from_path(path)%0A%0A    def __init__(self):%0A        super(ImgurStorage, self).__init__()%0A        self.client = ImgurClient(self.client_id, self.client_secret, self.access_token, self.refresh_token)%0A%0A    def _open(self, name, mode='rb'):%0A        file_url = %22http://i.imgur.com/%7B0%7D.png%22.format(name)%0A        r = requests.get(file_url)%0A        f = tempfile.NamedTemporaryFile(delete=False)%0A        for chunk in r.iter_content(chunk_size=512 * 1024):%0A                if chunk: # filter out keep-alive new chunks%0A                    f.write(chunk)%0A        f.close()%0A        return File(f)%0A%0A    def uploaded_path(self, name):%0A        try:%0A            path = safe_join(self.location, name)%0A        except ValueError:%0A            raise SuspiciousFileOperation(%22Attempted access to '%25s' denied.%22 %25 name)%0A        return os.path.normpath(path)%0A%0A    def get_available_name(self, name):%0A        return name%0A%0A    def _save(self, name, content):%0A        %22%22%22%0A        Saves new content to the file specified by name. The content should be%0A        a proper File object or any python file-like object, ready to be read%0A        from the beginning.%0A        %22%22%22%0A        # Get the proper name for the file, as it will actually be saved.%0A        if name is None:%0A            name = content.name%0A%0A        if not hasattr(content, 'chunks'):%0A            content = File(content)%0A%0A        content.open()%0A%0A        data = %7B%0A            'image': base64.b64encode(content.read()),%0A            'type': 'base64',%0A            'meta': %7B%7D%0A        %7D%0A        ret = self.client.make_request('POST', 'upload', data, True)%0A        content.close()%0A        return ret%5B%22id%22%5D%0A%0A    def url(self, name):%0A        return %22http://i.imgur.com/%7B0%7D.png%22.format(name)%0A%0A    def get_valid_name(self, name):%0A        return name%0A%0A    def exists(self, name):%0A        return True%0A

Add imgur upload example