文档中心 > 列举桶
列举桶

最近更新时间:2021-09-22

您可以列举所有的桶。以下代码用于列举所有的桶:

from src.ossConfig import ossConfig

import unicloud_oss.Oss as Oss


access_key = 'XXXXXXXXX'

secret_key = 'XXXXXXXXXXXXXXXXXXX'

endpoint_url = 'http://XXXXXXXXXXXXXXXXX.com'

config = ossConfig(access_key,secret_key,endpoint_url)


list_buckets = Oss.list_buckets(config)

if list_buckets is None:

    print("Error list buckets")

else:

    for bucket in list_buckets['Buckets']:

        print(f'  {bucket["Name"]}')