本文整理汇总了Python中oss2.BucketIterator方法的典型用法代码示例。如果您正苦于以下问题:Python oss2.BucketIterator方法的具体用法?Python oss2.BucketIterator怎么用?Python oss2.BucketIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oss2
的用法示例。
在下文中一共展示了oss2.BucketIterator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _list_bucket
# 需要导入模块: import oss2 [as 别名]
# 或者: from oss2 import BucketIterator [as 别名]
def _list_bucket(self, service):
return [bucket.name for bucket in BucketIterator(service)]
示例2: __init__
# 需要导入模块: import oss2 [as 别名]
# 或者: from oss2 import BucketIterator [as 别名]
def __init__(self, access_key_id, access_key_secret, host, bucket_name, keeps=None):
"""
access_key_id:
access_key_secret:
host: 域名,如 http://oss-cn-hangzhou.aliyuncs.com
bucket_name: 不需要在后台自动创建,也会自动创建好
"""
super(OSSBackend, self).__init__(keeps)
auth = oss2.Auth(access_key_id, access_key_secret)
self.bucket = oss2.Bucket(auth, host, bucket_name)
service = oss2.Service(auth, host)
if bucket_name not in [b.name for b in oss2.BucketIterator(service)]:
# 说明bucket不存在
self.bucket.create_bucket()
示例3: test_bucket_iterator
# 需要导入模块: import oss2 [as 别名]
# 或者: from oss2 import BucketIterator [as 别名]
def test_bucket_iterator(self):
service = oss2.Service(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT)
self.assertTrue(OSS_BUCKET in (b.name for b in oss2.BucketIterator(service, max_keys=2)))