def METHOD_NAME(self, filename):
    with open(filename, 'rb') as f:
        content = f.read()
    meta = self.distribution.metadata
    data = {
        ':action': 'doc_upload',
        'name': meta.get_name(),
        'content': (os.path.basename(filename), content),
    }
    # set up the authentication
    credentials = _encode(self.username + ':' + self.password)
    credentials = standard_b64encode(credentials).decode('ascii')
    auth = "Basic " + credentials
    body, ct = self._build_multipart(data)
    msg = "Submitting documentation to %s" % (self.repository)
    self.announce(msg, log.INFO)
    # build the Request
    # We can't use urllib2 since we need to send the Basic
    # auth right with the first request
    schema, netloc, url, params, query, fragments = urllib.parse.urlparse(
        self.repository
    )
    assert not params and not query and not fragments
    if schema == 'http':
        conn = http.client.HTTPConnection(netloc)
    elif schema == 'https':
        conn = http.client.HTTPSConnection(netloc)
    else:
        raise AssertionError("unsupported schema " + schema)
    data = ''
    try:
        conn.connect()
        conn.putrequest("POST", url)
        content_type = ct
        conn.putheader('Content-type', content_type)
        conn.putheader('Content-length', str(len(body)))
        conn.putheader('Authorization', auth)
        conn.endheaders()
        conn.send(body)
    except socket.error as e:
        self.announce(str(e), log.ERROR)
        return
    r = conn.getresponse()
    if r.status == 200:
        msg = 'Server response (%s): %s' % (r.status, r.reason)
        self.announce(msg, log.INFO)
    elif r.status == 301:
        location = r.getheader('Location')
        if location is None:
            location = 'https://pythonhosted.org/%s/' % meta.get_name()
        msg = 'Upload successful. Visit %s' % location
        self.announce(msg, log.INFO)
    else:
        msg = 'Upload failed (%s): %s' % (r.status, r.reason)
        self.announce(msg, log.ERROR)
    if self.show_response:
        print('-' * 75, r.read(), '-' * 75)