Skip to content

Commit

Permalink
fix: 解决appId被File::setAppId覆盖了的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed Jun 16, 2018
1 parent c3310a1 commit 9f50048
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Service/TencentyunCosV5.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,21 @@ class TencentyunCosV5 extends Tencentyun
*/
protected $client;

public function signUrl($url, $seconds = 60)
public function __construct(array $options = [])
{
// 默认域名直接使用
//$url = $this->getClient()->getObjectUrl($this->bucket, $url, $seconds);
parent::__construct($options);

// TODO 被 File::setAppId 覆盖了
$this->appId = $options['appId'];
}

$sign = $this->generateSign($seconds);
public function signUrl($url, $seconds = 60)
{
if ($this->domain) {
return $url . '?sign=' . $this->generateSign($seconds);
}

return $url . '?sign=' . $sign;
return $this->getClient()->getObjectUrl($this->bucket, $url, $seconds);
}

protected function generateSign($seconds)
Expand All @@ -59,8 +66,8 @@ protected function generateSign($seconds)
$bucket = $this->bucket;
$secretId = $this->secretId;
$secretKey = $this->secretKey;
$expired = time() + $seconds;
$current = time();
$expired = $current + $seconds;
$rdm = rand();

$sign = 'a=' . $appId . '&b=' . $bucket . '&k=' . $secretId
Expand Down

0 comments on commit 9f50048

Please sign in to comment.