예제 #1
0
 def test_batch_move_force(self):
     ret, info = self.bucket.copy(bucket_name, 'copyfrom', bucket_name, 'copyfrom', force='true')
     print(info)
     assert info.status_code == 200
     ops = build_batch_move(bucket_name, {'copyfrom': 'copyfrom'}, bucket_name, force='true')
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]['code'] == 200
예제 #2
0
 def test_batch_move_force(self):
     ret,info = self.bucket.copy(bucket_name, 'copyfrom', bucket_name, 'copyfrom', force='true')
     print(info)
     assert info.status_code == 200
     ops = build_batch_move(bucket_name, {'copyfrom':'copyfrom'}, bucket_name,force='true')
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]['code'] == 200
예제 #3
0
 def test_batch_move_force(self):
     ret, info = self.bucket.copy(bucket_name, "copyfrom", bucket_name, "copyfrom", force="true")
     print(info)
     assert info.status_code == 200
     ops = build_batch_move(bucket_name, {"copyfrom": "copyfrom"}, bucket_name, force="true")
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]["code"] == 200
예제 #4
0
 def move_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_move(source_bucket, pathdict, target_bucket)
     ret, info = bucket.batch(ops)
     return ret,info
예제 #5
0
 def move_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_move(source_bucket, pathdict, target_bucket)
     ret, info = bucket.batch(ops)
     return ret, info
예제 #6
0
 def test_batch_rename(self):
     key = 'rename'+rand_string(8)
     self.bucket.copy(bucket_name, 'copyfrom', bucket_name, key)
     key2 = key + 'rename'
     ops = build_batch_move(bucket_name, {key: key2}, bucket_name)
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]['code'] == 200
     ret, info = self.bucket.delete(bucket_name, key2)
     print(info)
     assert ret == {}
예제 #7
0
 def test_batch_rename(self):
     key = "rename" + rand_string(8)
     self.bucket.copy(bucket_name, "copyfrom", bucket_name, key)
     key2 = key + "rename"
     ops = build_batch_move(bucket_name, {key: key2}, bucket_name)
     ret, info = self.bucket.batch(ops)
     print(info)
     assert ret[0]["code"] == 200
     ret, info = self.bucket.delete(bucket_name, key2)
     print(info)
     assert ret == {}
예제 #8
0
def main():
    items = []
    keys = dict()
    q = Auth(accessKey, secretKey)
    bucketManager = BucketManager(q)
    data = bucketManager.list(bucket)
    if data[0].get("items"):
        items = data[0].get("items")
    for value in items:
        keys[value.get("key")] = value.get("key")
    # force为true时强制同名覆盖, 字典的键为原文件,值为目标文件
    ops = build_batch_move(bucket, keys, new, force='true')
    ret, info = bucketManager.batch(ops)
    print(ret)
    print(info)
    pass
예제 #9
0
# 批量移动文件,测试域名过期也可以用,但是只能在区域内移动,不能跨区域

from qiniu import build_batch_move, Auth, BucketManager
access_key = 'your_AK'
secret_key = 'your_SK'

q = Auth(access_key, secret_key)
bucket = BucketManager(q)
# 原空间
src_bucket_name = 'hdtraining'
# 目标空间
target_bucket_name = 'qiniuxyy'

# 字典的键为原文件,值为目标文件
parse = {'111.m3u8': '1', '3333.m3u8': '2', '9.18.mp4': '3'}

# force为true时强制同名覆盖,
ops = build_batch_move(src_bucket_name,
                       parse,
                       target_bucket_name,
                       force='true')
ret, info = bucket.batch(ops)
print(info)
예제 #10
0
# -*- coding: utf-8 -*-
"""
批量移动文件

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


from qiniu import build_batch_move, 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_move(src_bucket_name, {'src_key1': 'target_key1', 'src_key2': 'target_key2'}, target_bucket_name, force='true')
ret, info = bucket.batch(ops)
print(info)
예제 #11
0
# flake8: noqa
"""
批量移动文件

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

from qiniu import build_batch_move, 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_move(src_bucket_name, {
    'src_key1': 'target_key1',
    'src_key2': 'target_key2'
},
                       target_bucket_name,
                       force='true')
ret, info = bucket.batch(ops)
print(info)