docs: def upload_file(upload_url, upload_fields, filepath, callback=None):
      """Upload a pre-signed file to Cloudsmith."""
      upload_fields = list(six.iteritems(upload_fields))
      upload_fields.append(
          ("file", (os.path.basename(filepath), click.open_file(filepath, "rb")))
      )
      encoder = MultipartEncoder(upload_fields)
      monitor = MultipartEncoderMonitor(encoder, callback=callback)
  
      config = cloudsmith_api.Configuration()
      if config.proxy:
          proxies = {"http": config.proxy, "https": config.proxy}
      else:
          proxies = None
  
      headers = {"content-type": monitor.content_type}
  
      client = get_files_api()
      headers["user-agent"] = client.api_client.user_agent
  
      session = create_requests_session()
      resp = session.post(upload_url, data=monitor, headers=headers, proxies=proxies)
  
      try:
          resp.raise_for_status()
      except requests.RequestException as exc:
          raise ApiException(
              resp.status_code, headers=exc.response.headers, body=exc.response.content
          )