Skip to content

get_media async

get_media(
    application_id: ApplicationId,
    conversation_id: ConversationId,
    message_id: MessageId,
    media_id: MediaId,
    *,
    config_overrides: Optional[AsyncQBusinessClientConfig] = None,
) -> GetMediaResponse

Returns the image bytes corresponding to a media object. If you have implemented your own application with the Chat and ChatSync APIs, and have enabled content extraction from visual data in Amazon Q Business, you use the GetMedia API operation to download the images so you can show them in your UI with responses.

For more information, see Extracting semantic meaning from images and visuals.

Parameters:

  • application_id (ApplicationId) –

    The identifier of the Amazon Q Business which contains the media object.

  • conversation_id (ConversationId) –

    The identifier of the Amazon Q Business conversation.

  • message_id (MessageId) –

    The identifier of the Amazon Q Business message.

  • media_id (MediaId) –

    The identifier of the media object. You can find this in the sourceAttributions returned by the Chat, ChatSync, and ListMessages API responses.

Raises:

  • AccessDeniedException –

    You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.

  • InternalServerException –

    An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact Support for help.

  • LicenseNotFoundException –

    You don't have permissions to perform the action because your license is inactive. Ask your admin to activate your license and try again after your licence is active.

  • MediaTooLargeException –

    The requested media object is too large to be returned.

  • ResourceNotFoundException –

    The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.

  • ThrottlingException –

    The request was denied due to throttling. Reduce the number of requests and try again.

  • ValidationException –

    The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.

  • UnknownServiceError –

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

Source code in docs_src/capo_qbusiness/_services/async_q_business.py
async def get_media(
    self,
    application_id: "capo_qbusiness.types.application_id.ApplicationId",
    conversation_id: "capo_qbusiness.types.conversation_id.ConversationId",
    message_id: "capo_qbusiness.types.message_id.MessageId",
    media_id: "capo_qbusiness.types.media_id.MediaId",
    *,
    config_overrides: Optional[AsyncQBusinessClientConfig] = None,
) -> "capo_qbusiness.types.get_media_response.GetMediaResponse":
    """<p>Returns the image bytes corresponding to a media object. If you have implemented your own application with the Chat and ChatSync APIs, and have enabled content extraction from visual data in Amazon Q Business, you use the GetMedia API operation to download the images so you can show them in your UI with responses.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/extracting-meaning-from-images.html">Extracting semantic meaning from images and visuals</a>.</p>

    Args:
        application_id: <p>The identifier of the Amazon Q Business which contains the media object.</p>
        conversation_id: <p>The identifier of the Amazon Q Business conversation.</p>
        message_id: <p>The identifier of the Amazon Q Business message.</p>
        media_id: <p>The identifier of the media object. You can find this in the <code>sourceAttributions</code> returned by the <code>Chat</code>, <code>ChatSync</code>, and <code>ListMessages</code> API responses.</p>

    Raises:
        capo_qbusiness.errors.access_denied_exception.AccessDeniedException: <p> You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.</p>
        capo_qbusiness.errors.internal_server_exception.InternalServerException: <p>An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact <a href="http://aws.amazon.com/contact-us/">Support</a> for help.</p>
        capo_qbusiness.errors.license_not_found_exception.LicenseNotFoundException: <p>You don't have permissions to perform the action because your license is inactive. Ask your admin to activate your license and try again after your licence is active.</p>
        capo_qbusiness.errors.media_too_large_exception.MediaTooLargeException: <p>The requested media object is too large to be returned.</p>
        capo_qbusiness.errors.resource_not_found_exception.ResourceNotFoundException: <p>The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.</p>
        capo_qbusiness.errors.throttling_exception.ThrottlingException: <p>The request was denied due to throttling. Reduce the number of requests and try again.</p>
        capo_qbusiness.errors.validation_exception.ValidationException: <p>The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.</p>
        capo_qbusiness.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_qbusiness.types.get_media_request.GetMediaRequest]",
    ) -> AsyncOperationResponse[
        "capo_qbusiness.types.get_media_response.GetMediaResponse"
    ]:
        import capo_qbusiness._operations.expert_q.get_media

        (
            output,
            http_response,
        ) = await capo_qbusiness._operations.expert_q.get_media.async_get_media(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetMedia")
    )
    input_: capo_qbusiness.types.get_media_request.GetMediaRequest = {
        "application_id": application_id,
        "conversation_id": conversation_id,
        "message_id": message_id,
        "media_id": media_id,
    }

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