rs_batch_move.php 769 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. require_once __DIR__ . '/../autoload.php';
  3. use \Qiniu\Auth;
  4. $accessKey = getenv('QINIU_ACCESS_KEY');
  5. $secretKey = getenv('QINIU_SECRET_KEY');
  6. $bucket = getenv('QINIU_TEST_BUCKET');
  7. $auth = new Auth($accessKey, $secretKey);
  8. $config = new \Qiniu\Config();
  9. $bucketManager = new \Qiniu\Storage\BucketManager($auth, $config);
  10. //每次最多不能超过1000个
  11. $keys = array(
  12. 'qiniu.mp4',
  13. 'qiniu.png',
  14. 'qiniu.jpg'
  15. );
  16. $keyPairs = array();
  17. foreach ($keys as $key) {
  18. $keyPairs[$key . "_copy"] = $key . "_move";
  19. }
  20. $srcBucket = $bucket;
  21. $destBucket = $bucket;
  22. $ops = $bucketManager->buildBatchMove($srcBucket, $keyPairs, $destBucket, true);
  23. list($ret, $err) = $bucketManager->batch($ops);
  24. if ($err) {
  25. print_r($err);
  26. } else {
  27. print_r($ret);
  28. }