获取对象列表
获取文件列表
list_objects(bucket_name, prefix=None, recursive=False, start_after=None, include_user_meta=False, include_version=False, use_api_v1=False, use_url_encoding_type=True)
参数¶
参数 | 类型 | 描述 |
---|---|---|
bucket_name | str | 桶的名称 |
prefix | str | 对象名称前缀 |
recursive | bool | 是否遍历 |
start_after | str | 列出该名称之后的对象 |
include_user_meta | bool | 是否包含用户元数据 |
include_version | bool | 是否包含对象版本 |
use_api_v1 | bool | 是否使用ListObjectV1 S3 API版本 |
示例¶
# List objects information.
objects = client.list_objects("my-bucket")
for obj in objects:
print(obj)
# List objects information whose names starts with "my/prefix/".
objects = client.list_objects("my-bucket", prefix="my/prefix/")
for obj in objects:
print(obj)
# List objects information recursively.
objects = client.list_objects("my-bucket", recursive=True)
for obj in objects:
print(obj)
# List objects information recursively whose names starts with
# "my/prefix/".
objects = client.list_objects(
"my-bucket", prefix="my/prefix/", recursive=True,
)
for obj in objects:
print(obj)
# List objects information recursively after object name
# "my/prefix/world/1".
objects = client.list_objects(
"my-bucket", recursive=True, start_after="my/prefix/world/1",
)
for obj in objects:
print(obj)