Ei kuvausta

rs_download_urls.php 639B

1234567891011121314151617181920
  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. // 构建 Auth 对象
  8. $auth = new Auth($accessKey, $secretKey);
  9. // 私有空间中的外链 http(s)://<domain>/<file_key>,一定要带访问协议,也就是 http:// 或者 https://
  10. $baseUrl = 'http://if-pri.qiniudn.com/qiniu.png?imageView2/1/h/500';
  11. // 对链接进行签名,参考文档:https://developer.qiniu.com/kodo/manual/1656/download-private
  12. $signedUrl = $auth->privateDownloadUrl($baseUrl);
  13. echo $signedUrl;