put_bucketAccessStyleMode.php 738 B

123456789101112131415161718192021222324252627
  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. $auth = new Auth($accessKey, $secretKey);
  10. $config = new Config();
  11. $bucketManager = new BucketManager($auth, $config);
  12. $bucket = 'xxxx'; // 存储空间名称
  13. $mode = 1; // 关闭:0 ,开启:1
  14. // 存储空间 - 原图保护开关
  15. // 原图保护:https://developer.qiniu.com/kodo/kb/1359/what-is-the-original-protection
  16. list($ret, $err) = $bucketManager->putBucketAccessStyleMode($bucket, $mode);
  17. if ($err != null) {
  18. var_dump($err);
  19. } else {
  20. var_dump($ret);
  21. }