code: def upload(self, content, content_type, filename=None):
          
          try:
              response = self.api.media_upload(content, content_type, filename)
              if "content_uri" in response:
                  return response["content_uri"]
              else:
                  raise MatrixUnexpectedResponse(
                      "The upload was successful, but content_uri wasn't found."
                  )
          except MatrixRequestError as e:
              raise MatrixRequestError(
                  code=e.code,
                  content="Upload failed: %s" % e
              )
docs: Upload content to the home server and recieve a MXC url.
  
          Args:
              content (bytes): The data of the content.
              content_type (str): The mimetype of the content.
              filename (str): Optional. Filename of the content.
  
          Raises:
              MatrixUnexpectedResponse: If the homeserver gave a strange response
              MatrixRequestError: If the upload failed for some reason.