コード例 #1
0
def multi_copy(private_key_list: List[str]) -> List:
    access_key = Facade.config["qiniu"]["access_key"]
    secret_key = Facade.config["qiniu"]["secret_key"]
    # original code
    q = Auth(access_key, secret_key)
    bucket = BucketManager(q)

    # 1. what i do
    target_copy_dict = {}
    copy_key_list = []

    # 2. prepare copy name
    for private_key in private_key_list:
        target_copy_dict[private_key] = rename(private_key)
        copy_key_list.append(rename(private_key))

    public_bucket_name = Facade.config["qiniu"]["category"]["public"]["bucket"]
    private_bucket_name = Facade.config["qiniu"]["category"]["private"][
        "bucket"]

    logworker.warning('------multi_copy---------start')
    logworker.warning(public_bucket_name)
    logworker.warning(private_bucket_name)
    logworker.warning(copy_key_list)
    logworker.warning('end------multi_copy---------')

    # force为true时强制同名覆盖, 字典的键为原文件,值为目标文件
    ops = build_batch_copy(private_bucket_name,
                           target_copy_dict,
                           public_bucket_name,
                           force='false')
    ret, info = bucket.batch(ops)

    return ret, info, copy_key_list
コード例 #2
0
 def test_batch_copy_force(self):
     ops = build_batch_copy(bucket_name, {'copyfrom': 'copyfrom'},
                            bucket_name,
                            force='true')
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]['code'] == 200
コード例 #3
0
ファイル: test_qiniu.py プロジェクト: hepochen/python-sdk
 def test_batch_copy(self):
     key = 'copyto'+rand_string(8)
     ops = build_batch_copy(bucket_name, {'copyfrom': key}, bucket_name)
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]['code'] == 200
     ops = build_batch_delete(bucket_name, [key])
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]['code'] == 200
コード例 #4
0
ファイル: easy_qiniu.py プロジェクト: Lsgo/easy_qiniu
 def copy_files(self,source_bucket,target_bucket,pathdict={}):
     """Args:
     source_bucket: 'source_bucket'
     target_bucket:  'target_bucket'
     pathdict: {'source_file_name':'target_file_name',...}
     """
     bucket = BucketManager(self.__auth)
     ops = build_batch_copy(source_bucket, pathdict, target_bucket)
     ret, info = bucket.batch(ops)
     return ret,info
コード例 #5
0
 def copy_files(self, source_bucket, target_bucket, pathdict={}):
     """Args:
     source_bucket: 'source_bucket'
     target_bucket:  'target_bucket'
     pathdict: {'source_file_name':'target_file_name',...}
     """
     bucket = BucketManager(self.__auth)
     ops = build_batch_copy(source_bucket, pathdict, target_bucket)
     ret, info = bucket.batch(ops)
     return ret, info
コード例 #6
0
ファイル: test_qiniu.py プロジェクト: jemygraw/python-sdk
 def test_batch_copy_force(self):
     ops = build_batch_copy(bucket_name, {'copyfrom': 'copyfrom'}, bucket_name, force='true')
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]['code'] == 200
コード例 #7
0
ファイル: batch_copy.py プロジェクト: jemygraw/python-sdk
# -*- coding: utf-8 -*-
"""
批量拷贝文件

https://developer.qiniu.com/kodo/api/1250/batch
"""


from qiniu import build_batch_copy, Auth, BucketManager

access_key = ''

secret_key = ''

q = Auth(access_key, secret_key)

bucket = BucketManager(q)

src_bucket_name = ''

target_bucket_name = ''

# force为true时强制同名覆盖, 字典的键为原文件,值为目标文件
ops = build_batch_copy(src_bucket_name, {'src_key1': 'target_key1', 'src_key2': 'target_key2'}, target_bucket_name, force='true')
ret, info = bucket.batch(ops)
print(info)
コード例 #8
0
ファイル: batch_copy.py プロジェクト: c1xfr2e/muser
# -*- coding: utf-8 -*-
"""
批量拷贝文件

https://developer.qiniu.com/kodo/api/1250/batch
"""

from qiniu import build_batch_copy, Auth, BucketManager

access_key = ''

secret_key = ''

q = Auth(access_key, secret_key)

bucket = BucketManager(q)

src_bucket_name = ''

target_bucket_name = ''

# force为true时强制同名覆盖, 字典的键为原文件,值为目标文件
ops = build_batch_copy(src_bucket_name, {
    'src_key1': 'target_key1',
    'src_key2': 'target_key2'
},
                       target_bucket_name,
                       force='true')
ret, info = bucket.batch(ops)
print(info)
コード例 #9
0
ファイル: test_qiniu.py プロジェクト: qiniu/python-sdk
 def test_batch_copy_force(self):
     ops = build_batch_copy(bucket_name, {"copyfrom": "copyfrom"}, bucket_name, force="true")
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]["code"] == 200
コード例 #10
0
__author__ = 'yuandian'
# -*- coding: utf-8 -*-
# flake8: noqa
from qiniu import Auth
from qiniu import BucketManager
from qiniu import build_batch_copy

access_key = 'nyWhBA7y_0py9Kbopsi7vuZFcvhbBv5MnNe9DH0G'
secret_key = 'DQNeMFYIf3WTNfuOVaTZqQpdv7l2XwHPmXgyFwJH'

bucket_name = 'redcollar'

q = Auth(access_key, secret_key)
bucket = BucketManager(q)

ret, eof, info = bucket.list(bucket_name,prefix='image/custom/01/m/dy/DAA161A/B_64N1_', limit=1000)
items = ret.get('items')
for one in items:
    str_64N1 = one.get('key')
    if "B_64N1_" in str_64N1:
        str_64N0 = str_64N1.replace("B_64N1_", "B_64N0_")
        ops = build_batch_copy(bucket_name, {str_64N1: str_64N0}, bucket_name)
        ret, info1 = bucket.batch(ops)
        print(info1)