openload/openload.py
def upload_file(self, file_path, folder_id=None, sha1=None, httponly=False):
        """Calls upload_link request to get valid url, then it makes a post request with given file to be uploaded.
        No need to call upload_link explicitly since upload_file calls it.

        Note:
            If folder_id is not provided, the file will be uploaded to ``Home`` folder.

        Args:
            file_path (str): full path of the file to be uploaded.
            folder_id (:obj:`str`, optional): folder-ID to upload to.
            sha1 (:obj:`str`, optional): expected sha1 If sha1 of uploaded file doesn't match this value, upload fails.
            httponly (:obj:`bool`, optional): If this is set to true, use only http upload links.

        Returns:
            dict: dictionary containing uploaded file info. ::

                {
                    "content_type": "application/zip",
                    "id": "0yiQTPzi4Y4",
                    "name": 'favicons.zip',
                    "sha1": 'f2cb05663563ec1b7e75dbcd5b96d523cb78d80c',
                    "size": '24160',
                    "url": 'https://openload.co/f/0yiQTPzi4Y4/favicons.zip'
                 }

        """

        upload_url_response_json = self.upload_link(folder_id=folder_id, sha1=sha1, httponly=httponly)
        upload_url = upload_url_response_json['url']

        with open(file_path, 'rb') as f:
            response_json = requests.post(upload_url, files={'upload_file': f}).json()

        self._check_status(response_json)
        return response_json['result']
def upload_file(self, file_path, folder_id=None, sha1=None, httponly=False):
        upload_url_response_json = self.upload_link(folder_id=folder_id, sha1=sha1, httponly=httponly)
        upload_url = upload_url_response_json['url']

        with open(file_path, 'rb') as f:
            response_json = requests.post(upload_url, files={'upload_file': f}).json()

        self._check_status(response_json)
        return response_json['result']
def upload_file ( self , file_path , folder_id = None , sha1 = None , httponly = False ) : upload_url_response_json = self . upload_link ( folder_id = folder_id , sha1 = sha1 , httponly = httponly ) upload_url = upload_url_response_json [ 'url' ] with open ( file_path , 'rb' ) as f : response_json = requests . post ( upload_url , files = { 'upload_file' : f } ) . json ( ) self . _check_status ( response_json ) return response_json [ 'result' ]
Calls upload_link request to get valid url, then it makes a post request with given file to be uploaded.
        No need to call upload_link explicitly since upload_file calls it.

        Note:
            If folder_id is not provided, the file will be uploaded to ``Home`` folder.

        Args:
            file_path (str): full path of the file to be uploaded.
            folder_id (:obj:`str`, optional): folder-ID to upload to.
            sha1 (:obj:`str`, optional): expected sha1 If sha1 of uploaded file doesn't match this value, upload fails.
            httponly (:obj:`bool`, optional): If this is set to true, use only http upload links.

        Returns:
            dict: dictionary containing uploaded file info. ::

                {
                    "content_type": "application/zip",
                    "id": "0yiQTPzi4Y4",
                    "name": 'favicons.zip',
                    "sha1": 'f2cb05663563ec1b7e75dbcd5b96d523cb78d80c',
                    "size": '24160',
                    "url": 'https://openload.co/f/0yiQTPzi4Y4/favicons.zip'
                 }
Calls upload_link request to get valid url then it makes a post request with given file to be uploaded . No need to call upload_link explicitly since upload_file calls it .