diff --git a/src/Qcloud/Cos/Client.php b/src/Qcloud/Cos/Client.php index ae292639..4319e692 100644 --- a/src/Qcloud/Cos/Client.php +++ b/src/Qcloud/Cos/Client.php @@ -137,13 +137,13 @@ private function createPresignedUrl(RequestInterface $request, $expires) { return $this->signature->createPresignedUrl($request, $expires); } - public function getPresignetUrl($method, $args, $expires = null) { + public function getPresignetUrl($method, $args, $expires = "+30 minutes") { $command = $this->getCommand($method, $args); $request = $this->commandToRequestTransformer($command); return $this->createPresignedUrl($request, $expires); } - public function getObjectUrl($bucket, $key, $expires = null, array $args = array()) { + public function getObjectUrl($bucket, $key, $expires = "+30 minutes", array $args = array()) { $command = $this->getCommand('GetObject', $args + array('Bucket' => $bucket, 'Key' => $key)); $request = $this->commandToRequestTransformer($command); return $this->createPresignedUrl($request, $expires)->__toString(); diff --git a/src/Qcloud/Cos/Signature.php b/src/Qcloud/Cos/Signature.php index a9e03930..72e3ecbb 100644 --- a/src/Qcloud/Cos/Signature.php +++ b/src/Qcloud/Cos/Signature.php @@ -20,6 +20,9 @@ public function signRequest(RequestInterface $request) { return $request->withHeader('Authorization', $authorization); } public function createAuthorization(RequestInterface $request, $expires = "+30 minutes") { + if (is_null($expires)) { + $expires = "+30 minutes"; + } $signTime = (string)(time() - 60) . ';' . (string)(strtotime($expires)); $httpString = strtolower($request->getMethod()) . "\n" . urldecode($request->getUri()->getPath()) . "\n\nhost=" . $request->getHeader("Host")[0]. "\n";