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

Page updated May 3, 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 →

パスの使用

APIでpathパラメータを使用して、S3バケット内の任意のパスにアクセスできます。これは定義済みのprotectedprivate、またはguestフォルダアクセスレベルよりも多くの柔軟性を提供し、ニーズに合わせたストレージ構造を作成および管理できます。

注:pathパラメータは空にしたり、'/'(先頭スラッシュ)で始まることはできません

以下のセクションでは、パスベースのAPIで既存のguestprotected、およびprivateリソースを使用する方法について説明しています。

ゲストアクセスレベルの使用

import { getProperties } from 'aws-amplify/storage';
try {
const result = await getProperties({
path: 'public/album/2024/1.jpg',
});
console.log('File Properties ', result);
} catch (error) {
console.log('Error ', error);
}

保護されたアクセスレベルの使用

import { getProperties } from 'aws-amplify/storage';
try {
const result = await getProperties({
// `identityId`は、現在認証されているユーザーのIDを提供します
path: ({identityId}) => `protected/${identityId}/album/2024/1.jpg`,
});
console.log('File Properties ', result);
} catch (error) {
console.log('Error ', error);
}

プライベートアクセスレベルの使用

import { getProperties } from 'aws-amplify/storage';
try {
const result = await getProperties({
// `identityId`は、現在認証されているユーザーのIDを提供します
path: ({identityId}) => `private/${identityId}/album/2024/1.jpg`,
});
console.log('File Properties ', result);
} catch (error) {
console.log('Error ', error);
}