<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def upload_document_fileobj(file_obj, file_name, session, documents_resource, log=None):
 """Uploads a single file-like object to the One Codex server directly to S3. Parameters file_obj : `FilePassthru`, or a file-like object If a file-like object is given, its mime-type will be sent as 'text/plain'. Otherwise, `FilePassthru` will send a compressed type if the file is gzip'd or bzip'd. file_name : `string` The file_name you wish to associate this file with at One Codex. fields : `dict` Additional data fields to include as JSON in the POST. session : `requests.Session` Connection to One Codex API. documents_resource : `onecodex.models.Documents` Wrapped potion-client object exposing `init_upload` and `confirm_upload` routes to mainline. Notes ----- In contrast to `upload_sample_fileobj`, this method will /only/ upload to an S3 intermediate bucket--not via our direct proxy or directly to a user's S3 bucket with a signed request. Raises ------ UploadException In the case of a fatal exception during an upload. Returns ------- `string` containing sample UUID of newly uploaded file. """

    try:
        fields = documents_resource.init_multipart_upload()
    except requests.exceptions.HTTPError as e:
        raise_api_error(e.response, state="init")
    except requests.exceptions.ConnectionError:
        raise_connectivity_error(file_name)

    s3_upload = _s3_intermediate_upload(
        file_obj,
        file_name,
        fields,
        session,
        documents_resource._client._root_url + fields["callback_url"],  # full callback url
    )

    document_id = s3_upload.get("document_id", "<UUID not yet assigned>")

    logging.info("{}: finished as document {}".format(file_name, document_id))
    return document_id