def upload_chunked(self, filename, *args, **kwargs):
f = kwargs.pop('<STR_LIT:file>', None)<EOL>is_direct_message = kwargs.pop('<STR_LIT>', False)<EOL>headers, post_data, fp = API._chunk_media('<STR_LIT>', filename, self.max_size_chunked, form_field='<STR_LIT>', f=f, is_direct_message=is_direct_message)<EOL>kwargs.update({'<STR_LIT>': headers, '<STR_LIT>': post_data})<EOL>media_info = bind_api(<EOL>api=self,<EOL>path='<STR_LIT>',<EOL>method='<STR_LIT:POST>',<EOL>payload_type='<STR_LIT>',<EOL>allowed_param=[],<EOL>require_auth=True,<EOL>upload_api=True<EOL>)(*args, **kwargs)<EOL>if media_info.media_id:<EOL><INDENT>chunk_size = kwargs.pop('<STR_LIT>', <NUM_LIT> * <NUM_LIT>)<EOL>chunk_size = max(chunk_size, <NUM_LIT:16> * <NUM_LIT>)<EOL>fsize = getfilesize(filename, f)<EOL>nloops = int(fsize / chunk_size) + (<NUM_LIT:1> if fsize % chunk_size > <NUM_LIT:0> else <NUM_LIT:0>)<EOL>for i in range(nloops):<EOL><INDENT>headers, post_data, fp = API._chunk_media('<STR_LIT>', filename, self.max_size_chunked, chunk_size=chunk_size, f=fp, media_id=media_info.media_id, segment_index=i, is_direct_message=is_direct_message)<EOL>kwargs.update({ '<STR_LIT>': headers, '<STR_LIT>': post_data, '<STR_LIT>': RawParser() })<EOL>bind_api(<EOL>api=self,<EOL>path='<STR_LIT>',<EOL>method='<STR_LIT:POST>',<EOL>payload_type='<STR_LIT>',<EOL>allowed_param=[],<EOL>require_auth=True,<EOL>upload_api=True<EOL>)(*args, **kwargs)<EOL><DEDENT>headers, post_data, fp = API._chunk_media('<STR_LIT>', filename, self.max_size_chunked, media_id=media_info.media_id, is_direct_message=is_direct_message)<EOL>kwargs = {'<STR_LIT>': headers, '<STR_LIT>': post_data}<EOL>return bind_api(<EOL>api=self,<EOL>path='<STR_LIT>',<EOL>method='<STR_LIT:POST>',<EOL>payload_type='<STR_LIT>',<EOL>allowed_param=[],<EOL>require_auth=True,<EOL>upload_api=True<EOL>)(*args, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>return media_info<EOL><DEDENT>
:reference https://dev.twitter.com/rest/reference/post/media/upload-chunked
            :allowed_param: