async def upload_file(self, data: bytes, mime_type: Optional[str] = None) -> str:
        """
        Upload a file to the content repository. See also: `API reference`_

        Args:
            data: The data to upload.
            mime_type: The MIME type to send with the upload request.

        Returns:
            The MXC URI to the uploaded file.

        Raises:
            MatrixResponseError: If the response does not contain a ``content_uri`` field.

        .. _API reference:
           https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-media-r0-upload
        """
        await self.ensure_registered()
        if magic:
            mime_type = mime_type or magic.from_buffer(data, mime=True)
        resp = await self.client.request("POST", "", content=data,
                                         headers={"Content-Type": mime_type},
                                         api_path="/_matrix/media/r0/upload")
        try:
            return resp["content_uri"]
        except KeyError:
            raise MatrixResponseError("Media repo upload response did not contain content_uri.")
async def upload_file ( self , data : bytes , mime_type : Optional [ str ] = None ) -> str : await self . ensure_registered ( ) if magic : mime_type = mime_type or magic . from_buffer ( data , mime = True ) resp = await self . client . request ( "POST" , "" , content = data , headers = { "Content-Type" : mime_type } , api_path = "/_matrix/media/r0/upload" ) try : return resp [ "content_uri" ] except KeyError : raise MatrixResponseError ( "Media repo upload response did not contain content_uri." )
Upload a file to the content repository. See also: `API reference`_

        Args:
            data: The data to upload.
            mime_type: The MIME type to send with the upload request.

        Returns:
            The MXC URI to the uploaded file.

        Raises:
            MatrixResponseError: If the response does not contain a ``content_uri`` field.

        .. _API reference:
           https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-media-r0-upload