async def upload_media(self, file_,<EOL>media_type=None,<EOL>media_category=None,<EOL>chunked=None,<EOL>size_limit=None,<EOL>**params):
if isinstance(file_, str):<EOL><INDENT>url = urlparse(file_)<EOL>if url.scheme.startswith('<STR_LIT:http>'):<EOL><INDENT>media = await self._session.get(file_)<EOL><DEDENT>else:<EOL><INDENT>path = urlparse(file_).path.strip("<STR_LIT>")<EOL>media = await utils.execute(open(path, '<STR_LIT:rb>'))<EOL><DEDENT><DEDENT>elif hasattr(file_, '<STR_LIT>') or isinstance(file_, bytes):<EOL><INDENT>media = file_<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>media_size = await utils.get_size(media)<EOL>if chunked is not None:<EOL><INDENT>size_test = False<EOL><DEDENT>else:<EOL><INDENT>size_test = await self._size_test(media_size, size_limit)<EOL><DEDENT>if isinstance(media, aiohttp.ClientResponse):<EOL><INDENT>media = media.content<EOL><DEDENT>if chunked or (size_test and chunked is None):<EOL><INDENT>args = media, media_size, file_, media_type, media_category<EOL>response = await self._chunked_upload(*args, **params)<EOL><DEDENT>else:<EOL><INDENT>response = await self.upload.media.upload.post(media=media,<EOL>**params)<EOL><DEDENT>if not hasattr(file_, '<STR_LIT>') and not getattr(media, '<STR_LIT>', True):<EOL><INDENT>media.close()<EOL><DEDENT>return response<EOL>
upload a media on twitter

Parameters
----------
file_ : str or pathlib.Path or file
    Path to the file or file object
media_type : str, optional
    mime type of the media
media_category : str, optional
    Twitter's media category of the media, must be used with
    ``media_type``
chunked : bool, optional
    If True, force the use of the chunked upload for the media
size_limit : int, optional
    If set, the media will be sent using a multipart upload if
    its size is over ``size_limit`` bytes
params : dict
    parameters used when making the request

Returns
-------
.data_processing.PeonyResponse
    Response of the request