rs_change_mime.php 714 B

1234567891011121314151617181920212223242526272829
  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. // 修改文件的 MIME 类型信息
  14. // 参考文档:https://developer.qiniu.com/kodo/api/1252/chgm
  15. $key = 'qiniu.mp4';
  16. $newMime = 'video/x-mp4';
  17. list($ret, $err) = $bucketManager->changeMime($bucket, $key, $newMime);
  18. if ($err != null) {
  19. var_dump($err);
  20. } else {
  21. var_dump($ret);
  22. }