rs_batch_delete.php 629 B

12345678910111213141516171819202122232425262728
  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. $ops = $bucketManager->buildBatchDelete($bucket, $keys);
  17. list($ret, $err) = $bucketManager->batch($ops);
  18. if ($err) {
  19. print_r($err);
  20. } else {
  21. print_r($ret);
  22. }