rs_batch_change_mime.php 672B

1234567891011121314151617181920212223242526272829
  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. $keyMimePairs = array(
  12. 'qiniu.mp4' => 'video/x-mp4',
  13. 'qiniu.png' => 'image/x-png',
  14. 'qiniu.jpg' => 'image/x-jpg'
  15. );
  16. $ops = $bucketManager->buildBatchChangeMime($bucket, $keyMimePairs);
  17. list($ret, $err) = $bucketManager->batch($ops);
  18. if ($err) {
  19. print_r($err);
  20. } else {
  21. print_r($ret);
  22. }