File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff 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 );
You can’t perform that action at this time.
0 commit comments