def media_upload(self, filename, *args, **kwargs):
f = kwargs.pop('<STR_LIT:file>', None)<EOL>mime, _ = mimetypes.guess_type(filename)<EOL>size = getfilesize(filename, f)<EOL>if mime in IMAGE_MIMETYPES and size < self.max_size_standard:<EOL><INDENT>return self.image_upload(filename, file=f, *args, **kwargs)<EOL><DEDENT>elif mime in CHUNKED_MIMETYPES:<EOL><INDENT>return self.upload_chunked(filename, file=f, *args, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>raise TweepError("<STR_LIT>" % mime)<EOL><DEDENT>
:reference: https://dev.twitter.com/rest/reference/post/media/upload
            :reference https://dev.twitter.com/rest/reference/post/media/upload-chunked
            :allowed_param: