Без опису

rs_delete_after_days.php 723B

123456789101112131415161718192021222324252627
  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. $auth = new Auth($accessKey, $secretKey);
  9. $config = new \Qiniu\Config();
  10. $bucketManager = new \Qiniu\Storage\BucketManager($auth, $config);
  11. // 设置文件的生命周期
  12. // 参考文档:https://developer.qiniu.com/kodo/api/1732/update-file-lifecycle
  13. $key = 'qiniu.mp4';
  14. $days = 10; // 设置为 0 表示取消生命周期
  15. list($ret, $err) = $bucketManager->deleteAfterDays($bucket, $key, $days);
  16. if ($err != null) {
  17. var_dump($err);
  18. } else {
  19. var_dump($ret);
  20. }