パスの使用
APIでpathパラメータを使用して、S3バケット内の任意のパスにアクセスできます。これは定義済みのprotected、private、またはguestフォルダアクセスレベルよりも多くの柔軟性を提供し、ニーズに合わせたストレージ構造を作成および管理できます。
以下のセクションでは、パスベースのAPIで既存のguest、protected、および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);}