code: def upload_file(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 OSError 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)
  
imports: from base64 import standard_b64encode
  from distutils import log
  from distutils.errors import DistutilsOptionError
  import os
  import zipfile
  import tempfile
  import shutil
  import itertools
  import functools
  import http.client
  import urllib.parse
  from .._importlib import metadata
  from ..warnings import SetuptoolsDeprecationWarning
  from .upload import upload
label_desc: Use image node_id 8 for calling the upload_docs obj's underlying member method code with example usage: obj.upload_file(filename) without return types