Skip to content

Commit d96d7ac

Browse files
committed
fix test
1 parent 0943221 commit d96d7ac

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

sample.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,4 +654,35 @@
654654
print_r($result);
655655
} catch (\Exception $e) {
656656
echo "$e\n";
657+
}
658+
659+
660+
## 删除某些前缀的空bucket
661+
function startsWith($haystack, $needle)
662+
{
663+
$length = strlen($needle);
664+
return (substr($haystack, 0, $length) === $needle);
665+
}
666+
667+
try {
668+
$result = $cosClient->listBuckets();
669+
foreach ($result['Buckets'] as $bucket){
670+
$region = $bucket['Location'];
671+
$name = $bucket['Name'];
672+
if (startsWith($name,'lewzylu')){
673+
try {
674+
$cosClient2 = new Qcloud\Cos\Client(array('region' => $region,
675+
'credentials'=> array(
676+
'secretId' => getenv('COS_KEY'),
677+
'secretKey' => getenv('COS_SECRET'))));
678+
$rt = $cosClient2->deleteBucket(array('Bucket' => $name));
679+
print_r($rt);
680+
}catch (\Exception $e) {
681+
}
682+
}
683+
684+
685+
}
686+
} catch (\Exception $e) {
687+
echo "$e\n";
657688
}

src/Qcloud/Cos/Signature.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public function signRequest(RequestInterface $request) {
3434

3535
public function createPresignedUrl(
3636
RequestInterface $request,
37-
$expires = 3600
37+
$expires = "10 minutes"
3838
) {
39-
$signTime = (string)(time() - 60) . ';' . (string)(time() + (int)$expires);
39+
$signTime = (string)(time() - 60) . ';' . (string)(strtotime($expires));
4040
$httpString = strtolower($request->getMethod()) . "\n" . urldecode($request->getPath()) .
4141
"\n\nhost=" . $request->getHost() . "\n";
4242
$sha1edHttpString = sha1($httpString);

0 commit comments

Comments
 (0)