def _upload_file(self, fn):
size = os.path.getsize(fn)<EOL>counter = <NUM_LIT:0><EOL>base_name = os.path.basename(fn)<EOL>session_id = str(uuid.uuid4())<EOL>with open(fn, '<STR_LIT:rb>') as f:<EOL><INDENT>while True:<EOL><INDENT>response = None<EOL>chunk = f.read(CHUNK_SIZE)<EOL>if not chunk:<EOL><INDENT>break<EOL><DEDENT>for i in range(<NUM_LIT:5>):<EOL><INDENT>content_range = '<STR_LIT>'.format(counter * CHUNK_SIZE,<EOL>counter * CHUNK_SIZE + len(chunk) - <NUM_LIT:1>, size)<EOL>if i > <NUM_LIT:0> and response is not None:<EOL><INDENT>print("<STR_LIT>"<EOL>.format(response.status_code, content_range))<EOL><DEDENT>response = requests.post(urlparse.urljoin(self.url, '<STR_LIT>'),<EOL>auth=self.auth,<EOL>data=chunk,<EOL>headers={<EOL>'<STR_LIT>': '<STR_LIT>'.format(base_name),<EOL>'<STR_LIT>': size,<EOL>'<STR_LIT>': content_range,<EOL>'<STR_LIT:Content-Type>': '<STR_LIT>',<EOL>'<STR_LIT>': session_id})<EOL>if response.status_code in [<NUM_LIT:200>, <NUM_LIT>]:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>progress = <NUM_LIT> * (counter * CHUNK_SIZE + len(chunk)) / size<EOL>sys.stdout.write("<STR_LIT>".format(progress, fn))<EOL>sys.stdout.flush()<EOL>counter += <NUM_LIT:1><EOL><DEDENT><DEDENT>print()<EOL>return session_id<EOL>
Upload a single file on the platform.

        File is uploaded in chunks of 1,024 bytes.

        :param fn: File path
        :type fn: string