Use transfer acceleration
You can enable Transfer Acceleration for fast and secure transfer of files over long distances between your end user device and the S3 bucket. You can override the storage resource for this configuration and then leverage the useAccelerateEndpoint
parameter to use the accelerated S3 endpoint.
Override storage resource
Start by overriding your storage resources to enable Transfer Acceleration on your S3 bucket.
$ amplify override storage✅ Successfully generated "override.ts" folder at <project>/amplify/backend/storage/accelerated-bucket✔ Do you want to edit override.ts file now? (Y/n) · yesEdit the file in your editor: <project>/amplify/backend/storage/accelerated-bucket/override.ts
In the generated override.ts
file use the following CDK snippet to enable transfer acceleration.
// amplify/backend/storage/accelerated-bucket/override.tsimport { AmplifyS3ResourceTemplate } from '@aws-amplify/cli-extensibility-helper';
export function override(resources: AmplifyS3ResourceTemplate) { resources.s3Bucket.accelerateConfiguration = { accelerationStatus: 'Enabled' }}
Next, deploy this storage resource:
amplify push
Use Transfer Acceleration on Storage Operations
You can use transfer acceleration by setting "useAccelerateEndpoint"
to true
in the corresponding pluginOptions
for any of the following Storage APIs:
getUrl(path:options:)
downloadData(path:options:)
downloadFile(path:local:options:)
uploadData(path:data:options:)
uploadFile(path:local:options:)
getUrl(key:options:)
(Deprecated)downloadData(key:options:)
(Deprecated)downloadFile(key:local:options:)
(Deprecated)uploadData(key:data:options:)
(Deprecated)uploadFile(key:local:options:)
(Deprecated)
For example, to upload a file using transfer acceleration:
let uploadTask = Amplify.Storage.uploadFile( path: .fromString("public/example/key"), local: aLocalFile, options: .init( pluginOptions: [ "useAccelerateEndpoint": true ] ))
let data = try await uploadTask.value
let uploadTask = Amplify.Storage.uploadFile( key: aKey, local: aLocalFile, options: .init( pluginOptions: [ "useAccelerateEndpoint": true ] ))
let data = try await uploadTask.value