列举用户所有的Bucket[GetService], Endpoint类型为cname不能进行此操作
public listBuckets ( array $options = NULL ) : OSS\Model\BucketListInfo | ||
$options | array | |
Результат | OSS\Model\BucketListInfo |
public function testConstrunct8() { try { $ossClient = new OssClient(Config::OSS_ACCESS_ID, Config::OSS_ACCESS_KEY, "http://123.123.123.1", true); $ossClient->listBuckets(); $this->assertFalse(true); } catch (OssException $e) { } }
/** * 列出用户所有的Bucket * * @param OssClient $ossClient OssClient实例 * @return null */ function listBuckets($ossClient) { $bucketList = null; try { $bucketListInfo = $ossClient->listBuckets(); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print __FUNCTION__ . ": OK" . "\n"; $bucketList = $bucketListInfo->getBucketList(); foreach ($bucketList as $bucket) { print $bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n"; } }
public function testConstrunct9() { try { $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; $endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ '; $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); $ossClient->listBuckets(); } catch (OssException $e) { $this->assertFalse(true); } }