def upload_data(self, file_or_str, chunk_size=analyzere.upload_chunk_size,<EOL>poll_interval=analyzere.upload_poll_interval,<EOL>upload_callback=lambda x: None,<EOL>commit_callback=lambda x: None):
if not callable(upload_callback):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if not callable(commit_callback):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>file_obj = StringIO(file_or_str) if isinstance(<EOL>file_or_str, six.string_types) else file_or_str<EOL>length = None<EOL>if hasattr(file_obj, '<STR_LIT>'):<EOL><INDENT>length = utils.file_length(file_obj)<EOL>request_raw('<STR_LIT>', self._data_path,<EOL>headers={'<STR_LIT>': str(length)})<EOL><DEDENT>else:<EOL><INDENT>request_raw('<STR_LIT>', self._data_path)<EOL><DEDENT>for chunk, offset in utils.read_in_chunks(file_obj, chunk_size):<EOL><INDENT>headers = {'<STR_LIT>': str(offset),<EOL>'<STR_LIT:Content-Type>': '<STR_LIT>'}<EOL>request_raw('<STR_LIT>', self._data_path, headers=headers, body=chunk)<EOL>if length:<EOL><INDENT>upload_callback(offset * <NUM_LIT> / length)<EOL><DEDENT><DEDENT>upload_callback(<NUM_LIT>)<EOL>request_raw('<STR_LIT>', self._commit_path)<EOL>while True:<EOL><INDENT>resp = self.upload_status<EOL>if (resp.status == '<STR_LIT>' or resp.status == '<STR_LIT>'):<EOL><INDENT>commit_callback(<NUM_LIT>)<EOL>return resp<EOL><DEDENT>else:<EOL><INDENT>commit_callback(float(resp.commit_progress))<EOL>time.sleep(poll_interval)<EOL><DEDENT><DEDENT>
Accepts a file-like object or string and uploads it. Files are
automatically uploaded in chunks. The default chunk size is 16MiB and
can be overwritten by specifying the number of bytes in the
``chunk_size`` variable.
Accepts an optional poll_interval for temporarily overriding the
default value `analyzere.upload_poll_interval`.
Implements the tus protocol.
Takes optional callbacks that return the percentage complete for the
given "phase" of upload: upload/commit.
Callback values are returned as 10.0 for 10%