Ingen beskrivning

rs_move.php 769B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. require_once __DIR__ . '/../autoload.php';
  3. use Qiniu\Auth;
  4. // 控制台获取密钥:https://portal.qiniu.com/user/key
  5. $accessKey = getenv('QINIU_ACCESS_KEY');
  6. $secretKey = getenv('QINIU_SECRET_KEY');
  7. $bucket = getenv('QINIU_TEST_BUCKET');
  8. $key = "qiniu.mp4";
  9. $auth = new Auth($accessKey, $secretKey);
  10. $config = new \Qiniu\Config();
  11. $bucketManager = new \Qiniu\Storage\BucketManager($auth, $config);
  12. $srcBucket = $bucket;
  13. $destBucket = $bucket;
  14. $srcKey = $key . "_copy";
  15. $destKey = $key . "_move";
  16. // 资源移动或者重命名
  17. // 参考文档:https://developer.qiniu.com/kodo/api/1288/move
  18. list($ret, $err) = $bucketManager->move($srcBucket, $srcKey, $destBucket, $destKey, true);
  19. if ($err != null) {
  20. var_dump($err);
  21. } else {
  22. var_dump($ret);
  23. }