Sélectionner vos préférences de cookies

Nous utilisons des cookies essentiels et des outils similaires qui sont nécessaires au fonctionnement de notre site et à la fourniture de nos services. Nous utilisons des cookies de performance pour collecter des statistiques anonymes afin de comprendre comment les clients utilisent notre site et d’apporter des améliorations. Les cookies essentiels ne peuvent pas être désactivés, mais vous pouvez cliquer sur « Personnaliser » ou « Refuser » pour refuser les cookies de performance.

Si vous êtes d’accord, AWS et les tiers approuvés utiliseront également des cookies pour fournir des fonctionnalités utiles au site, mémoriser vos préférences et afficher du contenu pertinent, y compris des publicités pertinentes. Pour accepter ou refuser tous les cookies non essentiels, cliquez sur « Accepter » ou « Refuser ». Pour effectuer des choix plus détaillés, cliquez sur « Personnaliser ».

Working with Attachments - Amazon Connect
Cette page n'a pas été traduite dans votre langue. Demande de traduction

Working with Attachments

This topic explains how to work with attachments for Chat and Cases in Amazon Connect. For Chat Attachments, refer to the first section on the Amazon Connect Participant Service API. For Case Attachments, refer to the second section on the Amazon Connect service’s Attached Files APIs.

Uploading Attachments with the Participant Service

There are three basic steps for uploading a file using the Amazon Connect Participant Service API.

  1. HTTP POST file metadata to StartAttachmentUpload API, which will provide a signed Amazon S3 URL and attachment ID for uploading the file directly to Amazon S3.

  2. HTTP PUT file data to the signed Amazon S3 URL.

  3. HTTP POST attachment ID to CompleteAttachmentUpload to finalize the upload to Amazon S3.

Below is a basic JavaScript implementation for reference purposes.

//Define the html element for file using input tag <input type="file" id="fileUpload"> <input type="button" id="btnUploadFile" onclick="uploadFile()" value="Upload file"> async function uploadFile() { //Initiate the file upload by calling StartAttachmentUpload, providing the name, size, and content type of the file you want to upload. //The response will include a pre-signed URL and headers to use when building the file upload request, as well as an AttachmentId. const files = document.getElementById('fileUpload').files; const file = files[0]; const startUploadRequest = { AttachmentName: file.name, AttachmentSizeInBytes: file.size, ContentType: file.type }; const { AttachmentId, UploadMetadata } = await startAttachmentUpload(startUploadRequest); //Send the file data to the pre-signed S3 URL. //The file is stored in a temporary location in the S3 bucket. await uploadFileToS3(file, UploadMetadata.Url, UploadMetadata.HeadersToInclude); //Finalize the file upload by calling CompleteAttachmentUpload, providing the AttachmentId. //This moves the file to the final Attachments S3 path configured for the connect instance. const completeUploadRequest = { AttachmentIds: [ AttachmentId ] }; await completeAttachmentUpload(completeUploadRequest); } async function startAttachmentUpload(requestData){ const response = await fetch(StartAttachmentUploadEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' 'X-Amz-Bearer': ConnectionToken, }, body: JSON.stringify(requestData) }); return response.data; } async function uploadFileToS3(file, signedUrl, headersToInclude) { return fetch(signedUrl, { method: 'PUT', headers: headersToInclude, body: file }); } async function completeAttachmentUpload(requestData){ return fetch(CompleteAttachmentUploadEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' 'X-Amz-Bearer': ConnectionToken, }, body: JSON.stringify(requestData) }); }

For an example of a real world implementation, view the Amazon Connect ChatJS JavaScript client on GitHub.

Uploading Attached Files with the Connect Service

The same basic steps follow from the Participant service instructions, for usage with the Amazon Connect service’s attached file APIs.

  1. Call the StartAttachedFileUpload API with the required attached file information, which will provide a signed Amazon S3 URL, headers, and file ID for uploading the file directly to Amazon S3.

    1. If you are attaching a file to a Case, the calling identity must also have the cases:CreateRelatedItem permission on the target Case resource.

  2. Using your http client of choice, PUT file data to the signed Amazon S3 URL, ensuring that you add the headers as required from the response of Step 1.

  3. Call the CompleteAttachedFileUpload to finalize the upload to Amazon S3.

ConfidentialitéConditions d'utilisation du sitePréférences de cookies
© 2025, Amazon Web Services, Inc. ou ses affiliés. Tous droits réservés.