Classic/VPC環境で利用できます。
バケットに保存されているオブジェクトリストを照会します。
構文
list-objects構文は次の通りです。
aws s3api list-objects \
--bucket <bucket> \
[--delimiter <delimiter>] \
[--prefix <prefix>] \
[--starting-token <starting-token>] \
[--page-size <page-size>] \
[--max-items <max-items>] \
--endpoint-url <endpoint-url>
オプション
list-objectsの実行時に指定できるオプションについて説明します。
必須オプション
list-objectsの必須オプションです。
| オプション | タイプ | 必須の有無 | 説明 |
|---|---|---|---|
--bucket |
String | Required | バケット名 |
任意オプション
list-objectsの任意オプションです。指定しない場合、オプションにはデフォルト値が適用されます。
| オプション | タイプ | 必須の有無 | 説明 |
|---|---|---|---|
--delimiter |
String | Optional | オブジェクトをグループ化するための区切り文字
|
--prefix |
String | Optional | 照会する Prefix |
--starting-token |
String | Optional | 照会を開始する位置 |
--page-size |
Integer | Optional | ページごとの項目数
|
--max-items |
Integer | Optional | 出力に含める項目の総数 |
共通オプション
awsコマンドで共通して使用するオプションについては、Object Storageのオプションをご参照ください。
例
オブジェクトリストの照会リクエストが成功すると、各オブジェクトの識別情報とサイズが返されます。
コマンド
コマンドの例は次の通りです。
aws s3api list-objects --bucket my-test-bucket \
--endpoint-url=https://kr.object.ncloudstorage.com
接頭辞でオブジェクトを絞り込むコマンドの例は次の通りです。
aws s3api list-objects --bucket my-test-bucket \
--prefix docs/ \
--endpoint-url=https://kr.object.ncloudstorage.com
一度に照会できる件数を制限するコマンドの例は次の通りです。
aws s3api list-objects --bucket my-test-bucket \
--max-items 2 \
--page-size 2 \
--endpoint-url=https://kr.object.ncloudstorage.com
前回のレスポンスのNextTokenを使って次のページを照会するコマンドの例は次の通りです。
aws s3api list-objects --bucket my-test-bucket \
--max-items 2 \
--page-size 2 \
--starting-token eyJNYXJrZXIiOiAiaW1nL2ltYWdlLnBuZyJ9 \
--endpoint-url=https://kr.object.ncloudstorage.com
出力
出力の例は次の通りです。
{
"Contents": [
{
"Key": "docs/report.txt",
"LastModified": "2026-09-02T05:33:23.884Z",
"ETag": "\"2732fae1c46437ca8a558987ed1c1229\"",
"Size": 41,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
},
{
"Key": "img/image.png",
"LastModified": "2026-09-02T06:39:50.488Z",
"ETag": "\"2cd8bde463f5d82aae0f0cec061d6b8f\"",
"Size": 70,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
},
{
"Key": "large.bin",
"LastModified": "2026-09-02T06:41:01.883Z",
"ETag": "\"57325bca2c5c2cb6adf5aa9a66fb4e2d\"",
"Size": 5242880,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
},
{
"Key": "notes.txt",
"LastModified": "2026-09-02T05:33:24.692Z",
"ETag": "\"cc87f4af4dc404e7dd08a9309df6a374\"",
"Size": 24,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
},
{
"Key": "sample.txt",
"LastModified": "2026-09-02T05:33:23.549Z",
"ETag": "\"d48c6f4176cc2713372e2a605811ec19\"",
"Size": 46,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
}
],
"RequestCharged": null
}
接頭辞で絞り込んだ出力の例は次の通りです。
{
"Contents": [
{
"Key": "docs/report.txt",
"LastModified": "2026-09-02T05:33:23.884Z",
"ETag": "\"2732fae1c46437ca8a558987ed1c1229\"",
"Size": 41,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
}
],
"RequestCharged": null
}
一度に照会できる件数を制限した出力の例は次の通りです。次のページがある場合は、NextTokenが併せて返されます。
{
"Contents": [
{
"Key": "docs/report.txt",
"LastModified": "2026-09-02T05:33:23.884Z",
"ETag": "\"2732fae1c46437ca8a558987ed1c1229\"",
"Size": 41,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
},
{
"Key": "img/image.png",
"LastModified": "2026-09-02T06:39:50.488Z",
"ETag": "\"2cd8bde463f5d82aae0f0cec061d6b8f\"",
"Size": 70,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
}
],
"RequestCharged": null,
"NextToken": "eyJNYXJrZXIiOiAiaW1nL2ltYWdlLnBuZyJ9"
}
次のページを照会した出力の例は次の通りです。
{
"Contents": [
{
"Key": "large.bin",
"LastModified": "2026-09-02T06:41:01.883Z",
"ETag": "\"57325bca2c5c2cb6adf5aa9a66fb4e2d\"",
"Size": 5242880,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
},
{
"Key": "notes.txt",
"LastModified": "2026-09-02T05:33:24.692Z",
"ETag": "\"cc87f4af4dc404e7dd08a9309df6a374\"",
"Size": 24,
"StorageClass": "Standard",
"Owner": {
"DisplayName": "ncp-123456-0",
"ID": "ncp-123456-0"
}
}
],
"RequestCharged": null,
"NextToken": "eyJNYXJrZXIiOiAibm90ZXMudHh0In0="
}