Example #1
0
 def create_new_photo_upload_key(self, authorized_client, **kwargs):
     url = FiveHundredPx.BASE_URL + '/photos'
     url = url + "?" + smart_urlencode(kwargs)
     data = ""
     response = authorized_client.post(url, data=data)
     response_data = _parse_json(response.content)
     return response_data
Example #2
0
 def create_new_photo_upload_key(self, authorized_client, **kwargs):
     url = FiveHundredPx.BASE_URL + '/photos'
     url = url + "?" + smart_urlencode(kwargs)
     data = ""
     response = authorized_client.post(url, data=data)
     response_data = _parse_json(response.content)
     return response_data
Example #3
0
 def upload_photo(self, upload_key, photo_id, photo_file, authorized_client):
     """ This method is only useful for client side applications """
     files = {'file': photo_file}
     url = FiveHundredPx.BASE_URL + '/upload'
     access_key = authorized_client.access_token
     kwargs = dict(upload_key=upload_key,
                   photo_id=photo_id,
                   consumer_key=self.consumer_key,
                   access_key=access_key)
     url = url + "?" + smart_urlencode(kwargs)
     response = multipart_post(url, files=files)
     if response.status_code == 200:
         return True
     else:
         print response.content
Example #4
0
 def upload_photo(self, upload_key, photo_id, photo_file,
                  authorized_client):
     """ This method is only useful for client side applications """
     files = {'file': photo_file}
     url = FiveHundredPx.BASE_URL + '/upload'
     access_key = authorized_client.access_token
     kwargs = dict(upload_key=upload_key,
                   photo_id=photo_id,
                   consumer_key=self.consumer_key,
                   access_key=access_key)
     url = url + "?" + smart_urlencode(kwargs)
     response = multipart_post(url, files=files)
     if response.status_code == 200:
         return True
     else:
         print response.content
Example #5
0
    def use_authorized_client(self,
                              authorized_client,
                              url,
                              post_args=None,
                              skip=None,
                              rpp=None,
                              **kwargs):

        resp_data = None
        if skip:
            kwargs['skip'] = skip
        if rpp:
            kwargs['rpp'] = rpp
        if not post_args:
            url += "/?%s" % smart_urlencode(kwargs)
            resp_data = _parse_json(authorized_client.get(url).content)
        else:
            resp_data = _parse_json(
                authorized_client.post(url, data=post_args, **kwargs))
        return resp_data
Example #6
0
 def use_authorized_client(self,
                           authorized_client,
                           url,
                           post_args=None,
                           skip=None,
                           rpp=None,
                           **kwargs):
     
     resp_data = None
     if skip:
         kwargs['skip'] = skip
     if rpp:
         kwargs['rpp'] = rpp
     if not post_args:
         url += "/?%s" % smart_urlencode(kwargs)
         resp_data = _parse_json(authorized_client.get(url).content)
     else:
         resp_data = _parse_json(authorized_client.post(url,
                                                        data=post_args,
                                                        **kwargs))
     return resp_data