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

Page updated May 22, 2024

Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. New project should use Amplify Gen 2. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade. Switch to the latest Gen 2 docs →

転送アクセラレーションを使用する

Amplify Flutter v1 is deprecated as of April 30th, 2025. No new features or bug fixes will be added. Dependencies may become outdated and potentially introduce compatibility issues.

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.

転送アクセラレーションを使用すると、追加のデータ転送料金が発生する可能性があります。価格詳細については、Amazon S3の価格を参照してください。

転送アクセラレーションを有効にすると、エンドユーザーデバイスとS3バケット間の長距離での高速かつセキュアなファイル転送が可能になります。このセットアップではストレージリソースをオーバーライドし、useAccelerateEndpointパラメータを使用して加速S3エンドポイントを活用できます。

ストレージリソースのオーバーライド

まず、ストレージリソースをオーバーライドしてS3バケットで転送アクセラレーションを有効にします。

$ 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

生成されたoverride.tsファイルで、次のCDKスニペットを使用して転送アクセラレーションを有効にします。

// 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'
}
}

次に、このストレージリソースをデプロイします:

amplify push

ストレージ操作で転送アクセラレーションを使用する

以下のAPIを呼び出すときに転送アクセラレーションを使用できます:

  • getUrl
  • downloadData
  • downloadFile
  • uploadData
  • uploadFile

対応するStorage S3プラグインオプションでuseAccelerateEndpointtrueに設定して、加速S3エンドポイントを操作に適用します。例えば、転送アクセラレーションを使用してファイルをアップロードします:

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}');
}
}