Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated May 21, 2024

Use transfer acceleration

Amplify Flutter v1 is now in Maintenance Mode until April 30th, 2025. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v1.

Please use the latest version (v2) of Amplify Flutter to get started.

If you are currently using v1, follow these instructions to upgrade to v2.

When you use Transfer Acceleration, additional data transfer charges might apply. For more information about pricing, see Amazon S3 pricing.

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) · yes
Edit 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.ts
import { 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 when calling the following APIs:

  • getUrl
  • downloadData
  • downloadFile
  • uploadData
  • uploadFile

Set useAccelerateEndpoint to true in the corresponding Storage S3 plugin options to apply an accelerated S3 endpoint to the operation. For example, upload a file using transfer acceleration:

import 'package:amplify_storage_s3/amplify_storage_s3.dart';
Future<void> uploadFileUsingAcceleration(String filePath, String path) async {
final localFile = AWSFile.fromPath(filePath);
try {
final uploadFileOperation = Amplify.Storage.uploadFile(
localFile: localFile,
path: const StoragePath.fromString(path),
options: const StorageUploadFileOptions(
pluginOptions: S3UploadFilePluginOptions(
useAccelerateEndpoint: true,
),
),
);
final result = await uploadFileOperation.result;
safePrint('Uploaded file: ${result.uploadedItem.path}');
} on StorageException catch (error) {
safePrint('Something went wrong uploading file: ${error.message}');
}
}