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 →

トランスファーアクセラレーションを使用する

トランスファーアクセラレーションを使用する場合、追加のデータ転送料金が発生する可能性があります。料金の詳細については、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

加速されたS3エンドポイントを使用してファイルをアップロードする

useAccelerateEndpointパラメータをtrueに設定して、加速されたS3エンドポイントに切り替えます。たとえば、getUrlメソッドの場合:

const getUrlResult = await getUrl({
path: "album/2024/1.jpg",
options: {
useAccelerateEndpoint: true; // 加速エンドポイントを使用するかどうか。
},
});

次のStorage APIは加速エンドポイントをサポートします

  • getUrl
  • getProperties
  • list
  • remove
  • downloadData
  • uploadData