code: def upload_document(file_path, session, documents_resource, progressbar=None):
      
      if not isinstance(file_path, six.string_types):
          raise ValueError(
              "Expected file_path to be a string, got {}".format(type(file_path).__name__)
          )
  
      file_name, file_size, _ = _file_stats(file_path, enforce_fastx=False)
  
      # disable progressbar while keeping context manager
      if not progressbar:
          progressbar = FakeProgressBar()
  
      with progressbar as bar:
          fobj = FilePassthru(file_path, file_size, bar)
          document_id = upload_document_fileobj(fobj, file_name, session, documents_resource)
          bar.finish()
          return document_id
docs: Uploads multiple document files to the One Codex server directly to S3 via an intermediate
      bucket.
  
      Parameters
      ----------
      file_path : `str`
          A path to a file on the system.
      session : `requests.Session`
          Connection to One Codex API.
      documents_resource : `onecodex.models.Documents`
          Wrapped potion-client object exposing `init_upload` and `confirm_upload` methods.
      progressbar : `click.progressbar`, optional
          If passed, display a progress bar using Click.
  
      Raises
      ------
      UploadException
          In the case of a fatal exception during an upload.
  
      Returns
      -------
      A `str` document ID for the newly uploaded file.