Skip to content

create_presigned_url async

create_presigned_url(
    instance_id: InstanceId,
    card_id: UUID,
    app_id: UUID,
    file_contents_sha256: str,
    file_name: Filename,
    scope: DocumentScope,
    *,
    config_overrides: Optional[AsyncQAppsClientConfig] = None,
    session_id: Optional[UUID] = None,
) -> CreatePresignedUrlOutput

Creates a presigned URL for an S3 POST operation to upload a file. You can use this URL to set a default file for a FileUploadCard in a Q App definition or to provide a file for a single Q App run. The scope parameter determines how the file will be used, either at the app definition level or the app session level.

The IAM permissions are derived from the qapps:ImportDocument action. For more information on the IAM policy for Amazon Q Apps, see IAM permissions for using Amazon Q Apps.

Parameters:

  • instance_id (InstanceId) –

    The unique identifier of the Amazon Q Business application environment instance.

  • card_id (UUID) –

    The unique identifier of the card the file is associated with.

  • app_id (UUID) –

    The unique identifier of the Q App the file is associated with.

  • file_contents_sha256 (str) –

    The Base64-encoded SHA-256 digest of the contents of the file to be uploaded.

  • file_name (Filename) –

    The name of the file to be uploaded.

  • scope (DocumentScope) –

    Whether the file is associated with a Q App definition or a specific Q App session.

  • session_id (Optional[UUID], default: None ) –

    The unique identifier of the Q App session the file is associated with, if applicable.

Raises:

  • AccessDeniedException –

    The client is not authorized to perform the requested operation.

  • InternalServerException –

    An internal service error occurred while processing the request.

  • ThrottlingException –

    The requested operation could not be completed because too many requests were sent at once. Wait a bit and try again later.

  • UnauthorizedException –

    The client is not authenticated or authorized to perform the requested operation.

  • ValidationException –

    The input failed to satisfy the constraints specified by the service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Upload a file to a specific session

>>> await client.create_presigned_url(instance_id='0b95c9c4-89cc-4aa8-9aae-aa91cbec699f', file_contents_sha256='wXY7GD8m4fmHhdtuQyBdXzNQpdCseVwBcOBIlzfm+kg=', file_name='myFile.txt', card_id='82f69028-22a9-4bea-8727-0eabf58e9fed', app_id='4263767c-d889-4cb2-a8f6-8b649bc66af0', scope='SESSION', session_id='4f0e5b87-9d38-41cd-9eb4-ebce2f2917cc')
Upload a file into a application
>>> await client.create_presigned_url(instance_id='0b95c9c4-89cc-4aa8-9aae-aa91cbec699f', file_contents_sha256='wXY7GD8m4fmHhdtuQyBdXzNQpdCseVwBcOBIlzfm+kg=', file_name='anApplicationFile.txt', app_id='4263767c-d889-4cb2-a8f6-8b649bc66af0', card_id='7a11f34b-42d4-4bc8-b668-ae4a788dae1e', scope='APPLICATION')
Source code in docs_src/capo_qapps/_services/async_q_apps.py
async def create_presigned_url(
    self,
    instance_id: "capo_qapps.types.instance_id.InstanceId",
    card_id: "capo_qapps.types.uuid.UUID",
    app_id: "capo_qapps.types.uuid.UUID",
    file_contents_sha256: str,
    file_name: "capo_qapps.types.filename.Filename",
    scope: "capo_qapps.types.document_scope.DocumentScope",
    *,
    config_overrides: Optional[AsyncQAppsClientConfig] = None,
    session_id: Optional["capo_qapps.types.uuid.UUID"] = None,
) -> "capo_qapps.types.create_presigned_url_output.CreatePresignedUrlOutput":
    """<p>Creates a presigned URL for an S3 POST operation to upload a file. You can use this URL to set a default file for a <code>FileUploadCard</code> in a Q App definition or to provide a file for a single Q App run. The <code>scope</code> parameter determines how the file will be used, either at the app definition level or the app session level.</p> <note> <p>The IAM permissions are derived from the <code>qapps:ImportDocument</code> action. For more information on the IAM policy for Amazon Q Apps, see <a href="https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/deploy-q-apps-iam-permissions.html">IAM permissions for using Amazon Q Apps</a>.</p> </note>

    Args:
        instance_id: <p>The unique identifier of the Amazon Q Business application environment instance.</p>
        card_id: <p>The unique identifier of the card the file is associated with.</p>
        app_id: <p>The unique identifier of the Q App the file is associated with.</p>
        file_contents_sha256: <p>The Base64-encoded SHA-256 digest of the contents of the file to be uploaded.</p>
        file_name: <p>The name of the file to be uploaded.</p>
        scope: <p>Whether the file is associated with a Q App definition or a specific Q App session.</p>
        session_id: <p>The unique identifier of the Q App session the file is associated with, if applicable.</p>

    Raises:
        capo_qapps.errors.access_denied_exception.AccessDeniedException: <p>The client is not authorized to perform the requested operation.</p>
        capo_qapps.errors.internal_server_exception.InternalServerException: <p>An internal service error occurred while processing the request.</p>
        capo_qapps.errors.throttling_exception.ThrottlingException: <p>The requested operation could not be completed because too many requests were sent at once. Wait a bit and try again later.</p>
        capo_qapps.errors.unauthorized_exception.UnauthorizedException: <p>The client is not authenticated or authorized to perform the requested operation.</p>
        capo_qapps.errors.validation_exception.ValidationException: <p>The input failed to satisfy the constraints specified by the service.</p>
        capo_qapps.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Upload a file to a specific session

        >>> await client.create_presigned_url(instance_id='0b95c9c4-89cc-4aa8-9aae-aa91cbec699f', file_contents_sha256='wXY7GD8m4fmHhdtuQyBdXzNQpdCseVwBcOBIlzfm+kg=', file_name='myFile.txt', card_id='82f69028-22a9-4bea-8727-0eabf58e9fed', app_id='4263767c-d889-4cb2-a8f6-8b649bc66af0', scope='SESSION', session_id='4f0e5b87-9d38-41cd-9eb4-ebce2f2917cc')
        Upload a file into a application

        >>> await client.create_presigned_url(instance_id='0b95c9c4-89cc-4aa8-9aae-aa91cbec699f', file_contents_sha256='wXY7GD8m4fmHhdtuQyBdXzNQpdCseVwBcOBIlzfm+kg=', file_name='anApplicationFile.txt', app_id='4263767c-d889-4cb2-a8f6-8b649bc66af0', card_id='7a11f34b-42d4-4bc8-b668-ae4a788dae1e', scope='APPLICATION')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_qapps.types.create_presigned_url_input.CreatePresignedUrlInput]",
    ) -> AsyncOperationResponse[
        "capo_qapps.types.create_presigned_url_output.CreatePresignedUrlOutput"
    ]:
        import capo_qapps._operations.q_apps_service.create_presigned_url

        (
            output,
            http_response,
        ) = await capo_qapps._operations.q_apps_service.create_presigned_url.async_create_presigned_url(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePresignedUrl")
    )
    input_: capo_qapps.types.create_presigned_url_input.CreatePresignedUrlInput = {
        "instance_id": instance_id,
        "card_id": card_id,
        "app_id": app_id,
        "file_contents_sha256": file_contents_sha256,
        "file_name": file_name,
        "scope": scope,
    }
    if session_id is not None:
        input_["session_id"] = session_id

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output