getAttachedFile method
Provides a pre-signed URL for download of an approved attached file. This
API also returns metadata about the attached file. It will only return a
downloadURL if the status of the attached file is APPROVED.
May throw AccessDeniedException.
May throw InternalServiceException.
May throw InvalidRequestException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
Parameter associatedResourceArn :
The resource to which the attached file is (being) uploaded to. The
supported resources are Cases
and Email.
Parameter fileId :
The unique identifier of the attached file resource.
Parameter instanceId :
The unique identifier of the Connect Customer instance.
Parameter urlExpiryInSeconds :
Optional override for the expiry of the pre-signed S3 URL in seconds. The
default value is 300.
Implementation
Future<GetAttachedFileResponse> getAttachedFile({
required String associatedResourceArn,
required String fileId,
required String instanceId,
int? urlExpiryInSeconds,
}) async {
_s.validateNumRange(
'urlExpiryInSeconds',
urlExpiryInSeconds,
5,
300,
);
final $query = <String, List<String>>{
'associatedResourceArn': [associatedResourceArn],
if (urlExpiryInSeconds != null)
'urlExpiryInSeconds': [urlExpiryInSeconds.toString()],
};
final response = await _protocol.send(
payload: null,
method: 'GET',
requestUri:
'/attached-files/${Uri.encodeComponent(instanceId)}/${Uri.encodeComponent(fileId)}',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return GetAttachedFileResponse.fromJson(response);
}