startAttachedFileUpload method
Provides a pre-signed Amazon S3 URL in response for uploading your content.
May throw AccessDeniedException.
May throw InternalServiceException.
May throw InvalidRequestException.
May throw ResourceConflictException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
Parameter associatedResourceArn :
The resource to which the attached file is (being) uploaded to. The
supported resources are Cases
and Email.
Parameter fileName :
A case-sensitive name of the attached file being uploaded.
Parameter fileSizeInBytes :
The size of the attached file in bytes.
Parameter fileUseCaseType :
The use case for the file.
Parameter instanceId :
The unique identifier of the Connect Customer instance.
Parameter clientToken :
A unique, case-sensitive identifier that you provide to ensure the
idempotency of the request. If not provided, the Amazon Web Services SDK
populates this field. For more information about idempotency, see Making
retries safe with idempotent APIs.
Parameter createdBy :
Represents the identity that created the file.
Parameter tags :
The tags used to organize, track, or control access for this resource. For
example, { "Tags": {"key1":"value1", "key2":"value2"} }.
Parameter urlExpiryInSeconds :
Optional override for the expiry of the pre-signed S3 URL in seconds. The
default value is 300.
Implementation
Future<StartAttachedFileUploadResponse> startAttachedFileUpload({
required String associatedResourceArn,
required String fileName,
required int fileSizeInBytes,
required FileUseCaseType fileUseCaseType,
required String instanceId,
String? clientToken,
CreatedByInfo? createdBy,
Map<String, String>? tags,
int? urlExpiryInSeconds,
}) async {
_s.validateNumRange(
'fileSizeInBytes',
fileSizeInBytes,
1,
1152921504606846976,
isRequired: true,
);
_s.validateNumRange(
'urlExpiryInSeconds',
urlExpiryInSeconds,
5,
300,
);
final $query = <String, List<String>>{
'associatedResourceArn': [associatedResourceArn],
};
final $payload = <String, dynamic>{
'FileName': fileName,
'FileSizeInBytes': fileSizeInBytes,
'FileUseCaseType': fileUseCaseType.value,
'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
if (createdBy != null) 'CreatedBy': createdBy,
if (tags != null) 'Tags': tags,
if (urlExpiryInSeconds != null) 'UrlExpiryInSeconds': urlExpiryInSeconds,
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri: '/attached-files/${Uri.encodeComponent(instanceId)}',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return StartAttachedFileUploadResponse.fromJson(response);
}