getAttachment method
Provides a pre-signed URL for download of a completed attachment. This is an asynchronous API for use with active contacts.
For security recommendations, see Connect Customer Chat security best practices.
-
The participant role
CUSTOM_BOTis not permitted to access attachments customers may upload. AnAccessDeniedExceptioncan indicate that the participant may be a CUSTOM_BOT, and it doesn't have access to attachments. -
ConnectionTokenis used for invoking this API instead ofParticipantToken.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ThrottlingException.
May throw ValidationException.
Parameter attachmentId :
A unique identifier for the attachment.
Parameter connectionToken :
The authentication token associated with the participant's connection.
Parameter urlExpiryInSeconds :
The expiration time of the URL in ISO timestamp. It's specified in ISO
8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For example,
2019-11-08T02:41:28.172Z.
Implementation
Future<GetAttachmentResponse> getAttachment({
required String attachmentId,
required String connectionToken,
int? urlExpiryInSeconds,
}) async {
_s.validateNumRange(
'urlExpiryInSeconds',
urlExpiryInSeconds,
5,
300,
);
final headers = <String, String>{
'X-Amz-Bearer': connectionToken.toString(),
};
final $payload = <String, dynamic>{
'AttachmentId': attachmentId,
if (urlExpiryInSeconds != null) 'UrlExpiryInSeconds': urlExpiryInSeconds,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/participant/attachment',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return GetAttachmentResponse.fromJson(response);
}