本文整理汇总了Python中qiniu.BucketManager方法的典型用法代码示例。如果您正苦于以下问题:Python qiniu.BucketManager方法的具体用法?Python qiniu.BucketManager怎么用?Python qiniu.BucketManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qiniu
的用法示例。
在下文中一共展示了qiniu.BucketManager方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: teardown_class
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def teardown_class(cls):
"""Delete all files in the test bucket.
"""
storage = QiniuStorage()
auth = storage.auth
bucket = BucketManager(auth)
while True:
ret, eof, info = bucket.list(storage.bucket_name, limit=100)
if ret is None:
print(info)
break
for item in ret['items']:
name = item['key']
if six.PY2:
name = name.encode('utf-8')
ret, info = bucket.delete(storage.bucket_name, name)
if ret is None:
print(info)
if eof:
break
示例2: main
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def main():
auth = Auth(QINIU_ACCESS_KEY, QINIU_SECRET_KEY)
bucket = BucketManager(auth)
while True:
ret, eof, info = bucket.list(QINIU_BUCKET_NAME, limit=100)
if ret is None:
print info
break
for item in ret['items']:
name = item['key']
print "Deleting %s ..." % name
ret, info = bucket.delete(QINIU_BUCKET_NAME, name)
if ret is None:
print info
if eof:
break
示例3: upload
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def upload(self, picture_path_list, link_only=False):
if self.upload_handler:
success_uploaded_list = []
for picture_path in picture_path_list:
picture_name = os.path.basename(picture_path)
token = self.upload_handler.upload_token(self.container_name, picture_name, 3600)
ret, info = put_file(token, picture_name, picture_path)
bucket = BucketManager(self.upload_handler)
success = bucket.stat(self.container_name, picture_name)
print(success)
self.write_markdown_picture_url(picture_path_list, link_only)
示例4: __init__
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def __init__(
self,
access_key=QINIU_ACCESS_KEY,
secret_key=QINIU_SECRET_KEY,
bucket_name=QINIU_BUCKET_NAME,
bucket_domain=QINIU_BUCKET_DOMAIN,
secure_url=QINIU_SECURE_URL):
self.auth = Auth(access_key, secret_key)
self.bucket_name = bucket_name
self.bucket_domain = bucket_domain
self.bucket_manager = BucketManager(self.auth)
self.secure_url = secure_url
示例5: teardown_class
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def teardown_class(cls):
"""Delete all files in the test bucket.
"""
storage = QiniuPrivateStorage(
bucket_name=get_qiniu_config('QINIU_PRIVATE_BUCKET_NAME'),
bucket_domain=get_qiniu_config('QINIU_PRIVATE_BUCKET_DOMAIN'),
)
auth = storage.auth
bucket = BucketManager(auth)
while True:
ret, eof, info = bucket.list(storage.bucket_name, limit=100)
if ret is None:
print(info)
break
for item in ret['items']:
name = item['key']
if six.PY2:
name = name.encode('utf-8')
ret, info = bucket.delete(storage.bucket_name, name)
if ret is None:
print(info)
if eof:
break
示例6: get_bucket_mgr
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def get_bucket_mgr(self):
if not self._bucket_mgr:
ak = self.access_key
sk = self.secret_key
q = Auth(ak, sk)
self._bucket_mgr = BucketManager(q)
return self._bucket_mgr
示例7: media_fetch_to_qiniu
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def media_fetch_to_qiniu(media_url, media_id):
'''抓取url的资源存储在库'''
auth = qiniu_auth()
bucket = BucketManager(auth)
bucket_name = Config.QINIU_BUCKET
ret, info = bucket.fetch(media_url, bucket_name, media_id)
if info.status_code == 200:
return True, media_id
return False, None
示例8: delete
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def delete(self, filename):
auth = QiniuClass.Auth(self._access_key, self._secret_key)
bucket = QiniuClass.BucketManager(auth)
return bucket.delete(self._bucket_name, filename)
示例9: qiniu_fetch_img
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def qiniu_fetch_img(img_url, img_name):
q = qiniu.Auth(QINIU_ACCESS_KEY, QINIU_SECRET_KEY)
token = q.upload_token(QINIU_BUCKET_NAME)
bucket = qiniu.BucketManager(q)
ret, info = bucket.fetch(img_url, QINIU_BUCKET_NAME, img_name)
if not ret:
return None
key = ret.get('key')
return QINIU_URL + key
# print dir(qiniu)
# return 'aa'
示例10: delete
# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import BucketManager [as 别名]
def delete(self, filename):
auth = Auth(self._access_key, self._secret_key)
bucket = BucketManager(auth)
# 删除bucket_name 中的文件 key
ret, info = bucket.delete(self._bucket_name, filename)
print(info)
try:
assert ret == {}
except Exception as e:
current_app.logger.info(e)
return ret, info