选择您的 Cookie 首选项

我们使用必要 Cookie 和类似工具提供我们的网站和服务。我们使用性能 Cookie 收集匿名统计数据,以便我们可以了解客户如何使用我们的网站并进行改进。必要 Cookie 无法停用,但您可以单击“自定义”或“拒绝”来拒绝性能 Cookie。

如果您同意,AWS 和经批准的第三方还将使用 Cookie 提供有用的网站功能、记住您的首选项并显示相关内容,包括相关广告。要接受或拒绝所有非必要 Cookie,请单击“接受”或“拒绝”。要做出更详细的选择,请单击“自定义”。

Working with Attachments

聚焦模式
Working with Attachments - Amazon Connect
此页面尚未翻译为您的语言。 请求翻译

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.

隐私网站条款Cookie 首选项
© 2025, Amazon Web Services, Inc. 或其附属公司。保留所有权利。