public getBucketCors ( string $bucket, array $options = NULL ) : OSS\Model\CorsConfig | ||
$bucket | string | bucket名称 |
$options | array | 可以为空 |
리턴 | OSS\Model\CorsConfig |
public function getBucketCors($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_OBJECT] = '/';
$options[self::OSS_SUB_RESOURCE] = 'cors';
$response = $this->auth($options);
$result = new GetCorsResult($response, __FUNCTION__);
return $result->getData();
}
/** * 获取并打印bucket的cors配置 * * @param OssClient $ossClient OssClient实例 * @param string $bucket 存储空间名称 * @return null */ function getBucketCors($ossClient, $bucket) { $corsConfig = null; try { $corsConfig = $ossClient->getBucketCors($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print __FUNCTION__ . ": OK" . "\n"; print $corsConfig->serializeToXml() . "\n"; }