本文整理匯總了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)))