diff --git a/src/qcloud/cos/Auth.php b/src/qcloud/cos/Auth.php index 419e180..312b506 100644 --- a/src/qcloud/cos/Auth.php +++ b/src/qcloud/cos/Auth.php @@ -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; @@ -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); } } @@ -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); }