使用PHP SDK删除COS上文件,提示Bucket不存在
配置文件:
'cos' => [ 'region' => 'cn-sorth', 'fileBucket' => 'wafer', 'uploadFolder' => 'pic', 'appID' => '1256827978' ],
控制器:
Version:1.0 StartHTML:0000000128 EndHTML:0000004192 StartFragment:0000000128 EndFragment:0000004192 SourceURL:about:blank
$cosClient = Cos::getInstance();
$cosConfig = Conf::getCos();
$bucketName = $cosConfig['fileBucket'];
$appId = $cosConfig['appID'];
$bucket_name = $bucketName."-".$appId;
echo $bucket_name;
$result = $cosClient->listBuckets();
var_dump($result);
$b_result = $cosClient->headBucket(array('Bucket' => $bucket_name));
var_dump($b_result);
$result = $cosClient->deleteObject(array(
'Bucket' => $bucket_name,
'Key' => $key));
return $result ;
echo $bucket_name;
输出:wafer-1256827978
$result = $cosClient->listBuckets();
var_dump($result);
输出:
object(Guzzle\Service\Resource\Model)#68 (2) {
["structure":protected]=>
NULL
["data":protected]=>
array(3) {
["Owner"]=>
array(2) {
["ID"]=>
string(43) "qcs::cam::uin/100005875745:uin/100005875745"
["DisplayName"]=>
string(12) "100005875745"
}
["Buckets"]=>
array(2) {
[0]=>
array(3) {
["Name"]=>
string(22) "nongjiayuan-1256827978"
["Location"]=>
string(10) "ap-beijing"
["CreationDate"]=>
string(20) "2018-06-08T01:53:20Z"
}
[1]=>
array(3) {
["Name"]=>
string(16) "wafer-1256827978"
["Location"]=>
string(12) "ap-guangzhou"
["CreationDate"]=>
string(20) "2018-06-08T05:47:06Z"
}
}
["RequestId"]=>
string(40) "NWIxYjc4N2RfYThhYjM1MGFfYjI4Ml8xNmQzOWY="
}
}
报错:
<h4>An uncaught Exception was encountered</h4>
<p>Type: Guzzle\Common\Exception\InvalidArgumentException</p>
<p>Message: Command was not found matching HeadBucket</p>
<p>Filename: /data/release/php-weapp-demo/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php</p>
<p>Line Number: 87</p>
明明名字完全一样为什么还是找不到?????
相似问题