Skip to content

Commit

Permalink
support calc download sign
Browse files Browse the repository at this point in the history
  • Loading branch information
wangnan8791 committed Jan 10, 2018
1 parent 95644c7 commit 2268b68
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/qcloud/cos/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct($appId, $secretId, $secretKey) {
* Return the signature on success.
* Return error code if parameter is not valid.
*/
public function createReusableSignature($expiration, $bucket, $filepath = null) {
public function createReusableSignature($expiration, $bucket, $filepath = null, $uploadFlag = true) {
$appId = $this->appId;
$secretId = $this->secretId;
$secretKey = $this->secretKey;
Expand All @@ -44,7 +44,11 @@ public function createReusableSignature($expiration, $bucket, $filepath = null)
$filepath = '/' . $filepath;
}

$fileId = '/' . $appId . '/' . $bucket . $filepath;
if ($uploadFlag) {
$fileId = '/' . $appId . '/' . $bucket . $filepath;
} else {
$fileId = $filepath;
}
return $this->createSignature($appId, $secretId, $secretKey, $expiration, $bucket, $fileId);
}
}
Expand All @@ -67,8 +71,8 @@ public function createNonreusableSignature($bucket, $filepath) {
if (preg_match('/^\//', $filepath) == 0) {
$filepath = '/' . $filepath;
}
$fileId = '/' . $appId . '/' . $bucket . $filepath;

$fileId = '/' . $appId . '/' . $bucket . $filepath;
return $this->createSignature($appId, $secretId, $secretKey, 0, $bucket, $fileId);
}

Expand Down

0 comments on commit 2268b68

Please sign in to comment.