rs_batch_restore_ar.php 934 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. require_once __DIR__ . '/../autoload.php';
  3. use Qiniu\Auth;
  4. use Qiniu\Config;
  5. use Qiniu\Storage\BucketManager;
  6. // 控制台获取密钥:https://portal.qiniu.com/user/key
  7. $accessKey = getenv('QINIU_ACCESS_KEY');
  8. $secretKey = getenv('QINIU_SECRET_KEY');
  9. $bucket = getenv('QINIU_TEST_BUCKET');
  10. $auth = new Auth($accessKey, $secretKey);
  11. $config = new Config();
  12. $bucketManager = new BucketManager($auth, $config);
  13. // 批量解冻归档/深度归档文件,每次最多不能超过 1000 个
  14. $keys = array(
  15. 'archived_file.mp4',
  16. 'deep_archived_file.png',
  17. 'others.jpg'
  18. );
  19. $keyTypePairs = array();
  20. // key 是文件
  21. // value 是解冻时间(单位:天,范围 1~7)
  22. foreach ($keys as $key) {
  23. $keyTypePairs[$key] = 1;
  24. }
  25. $ops = BucketManager::buildBatchRestoreAr($bucket, $keyTypePairs);
  26. list($ret, $err) = $bucketManager->batch($ops);
  27. if ($err != null) {
  28. var_dump($err);
  29. } else {
  30. var_dump($ret);
  31. }