当前位置: 首页>>代码示例>>Python>>正文


Python qiniu.BucketManager方法代码示例

本文整理汇总了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 
开发者ID:glasslion,项目名称:django-qiniu-storage,代码行数:25,代码来源:test_storage.py

示例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 
开发者ID:glasslion,项目名称:django-qiniu-storage,代码行数:21,代码来源:clear_qiniu_bucket.py

示例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) 
开发者ID:kingname,项目名称:MarkdownPicPicker,代码行数:13,代码来源:QiniuUploader.py

示例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 
开发者ID:glasslion,项目名称:django-qiniu-storage,代码行数:15,代码来源:backends.py

示例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 
开发者ID:glasslion,项目名称:django-qiniu-storage,代码行数:28,代码来源:test_private_storage.py

示例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 
开发者ID:haizi-zh,项目名称:scrapy-qiniu,代码行数:10,代码来源:impl.py

示例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 
开发者ID:gusibi,项目名称:momo,代码行数:11,代码来源:media.py

示例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) 
开发者ID:csuzhangxc,项目名称:Flask-QiniuStorage,代码行数:6,代码来源:flask_qiniustorage.py

示例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' 
开发者ID:GitMarkTeam,项目名称:gitmark,代码行数:16,代码来源:wrap_qiniu.py

示例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 
开发者ID:adisonhuang,项目名称:flask-blog,代码行数:13,代码来源:qiniustorage.py


注:本文中的qiniu.BucketManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。