docs: def _s3_intermediate_upload(file_obj, file_name, fields, session, callback_url):
      """Uploads a single file-like object to an intermediate S3 bucket which One Codex can pull from
      after receiving a callback.
  
      Parameters
      ----------
      file_obj : `FASTXInterleave`, `FilePassthru`, or a file-like object
          A wrapper around a pair of fastx files (`FASTXInterleave`) or a single fastx file. In the
          case of paired files, they will be interleaved and uploaded uncompressed. In the case of a
          single file, it will simply be passed through (`FilePassthru`) to One Codex, compressed
          or otherwise. If a file-like object is given, its mime-type will be sent as 'text/plain'.
      file_name : `string`
          The file_name you wish to associate this fastx file with at One Codex.
      fields : `dict`
          Additional data fields to include as JSON in the POST.
      callback_url : `string`
          API callback at One Codex which will trigger a pull from this S3 bucket.
  
      Raises
      ------
      UploadException
          In the case of a fatal exception during an upload. Note we rely on boto3 to handle its own retry logic.
  
      Returns
      -------
      `dict` : JSON results from internal confirm import callback URL
      """
      import boto3
      from boto3.s3.transfer import TransferConfig
      from boto3.exceptions import S3UploadFailedError
  
      # actually do the upload
      client = boto3.client(
          "s3",
          aws_access_key_id=fields["upload_aws_access_key_id"],
          aws_secret_access_key=fields["upload_aws_secret_access_key"],
      )
  
      # if boto uses threads, ctrl+c won't work
      config = TransferConfig(use_threads=False)
  
      # let boto3 update our progressbar rather than our FASTX wrappers, if applicable
      boto_kwargs = {}
  
      if hasattr(file_obj, "progressbar"):
          boto_kwargs["Callback"] = file_obj.progressbar.update
          file_obj.progressbar = None
  
      try:
          client.upload_fileobj(
              file_obj,
              fields["s3_bucket"],
              fields["file_id"],
              ExtraArgs={"ServerSideEncryption": "AES256"},
              Config=config,
              **boto_kwargs
          )
      except S3UploadFailedError:
          raise_connectivity_error(file_name)
  
      # issue a callback
      try:
          resp = session.post(
              callback_url,
              json={
                  "s3_path": "s3://{}/{}".format(fields["s3_bucket"], fields["file_id"]),
                  "filename": file_name,
                  "import_as_document": fields.get("import_as_document", False),
              },
          )
      except requests.exceptions.ConnectionError:
          raise_connectivity_error(file_name)
  
      if resp.status_code != 200:
          raise_connectivity_error(file_name)
  
      try:
          return resp.json()
      except ValueError:
          return {}