文档首页> OBS PHP SDK> API参考> 桶相关接口> 获取桶的Website配置
更新时间:2021-03-18 GMT+08:00
分享

获取桶的Website配置

功能说明

获取桶的Website配置。

方法定义

1. ObsClient->getBucketWebsite(array $parameter)
2. ObsClient->getBucketWebsiteAsync(array $parameter, callable $callback)

请求参数

字段名

类型

约束

说明

Bucket

string

必选

桶名。

返回结果

字段名

类型

说明

HttpStatusCode

integer

HTTP状态码。

Reason

string

HTTP文本描述。

RequestId

string

OBS服务端返回的请求ID。

RedirectAllRequestsTo

associative array

所有请求重定向的规则。

  

HostName

  

string

重定向时使用的站点名。

Protocol

  

string

重定向时使用的协议。

ErrorDocument

associative array

错误页面配置。

  

Key

  

string

指定当4XX错误出现时返回的页面。

IndexDocument

associative array

默认页面配置。

  

Suffix

  

string

该字段被追加在对文件夹的请求的末尾(例如:配置的是“index.html”,请求的是“samplebucket/images/”,返回的数据将是“samplebucket”桶内名为“images/index.html”的对象的内容)。该字段不能为空或者包含“/”字符。

RoutingRules

indexed array

重定向规则列表。

  

Condition

associative array

重定向规则的匹配条件。

  

HttpErrorCodeReturnedEquals

integer

重定向规则生效需要匹配的HTTP错误码。

KeyPrefixEquals

string

重定向规则生效需要匹配的对象名前缀。

Redirect

associative array

重定向请求时的具体信息。

  

Protocol

string

重定向请求时使用的协议。

HostName

string

重定向请求时使用的站点名。

ReplaceKeyPrefixWith

string

重定向请求时使用的对象名前缀。

ReplaceKeyWith

string

重定向请求时使用的对象名。不可与ReplaceKeyPrefixWith同时存在。

HttpRedirectCode

integer

重定向请求时响应中的HTTP状态码。

代码样例

try{
       $resp = $obsClient -> getBucketWebsite([
              'Bucket' => 'bucketname'
       ]);
       printf("RequestId:%s\n", $resp['RequestId']);
       printf("ErrorDocument[Key]:%s\n", $resp['ErrorDocument']['Key']);
       printf("IndexDocument[Suffix]:%s\n", $resp['IndexDocument']['Suffix']);
       foreach ($resp['RoutingRules'] as $index => $routingRule){
              printf("RoutingRules[%d]", $index + 1);
              printf("Condition[HttpErrorCodeReturnedEquals]:%s\n", $routingRule['Condition']['HttpErrorCodeReturnedEquals']);
              printf("Condition[KeyPrefixEquals]:%s\n", $routingRule['Condition']['KeyPrefixEquals']);
              printf("Redirect[Protocol]:%s\n", $routingRule['Redirect']['Protocol']);
              printf("Redirect[ReplaceKeyWith]:%s\n", $routingRule['Redirect']['ReplaceKeyWith']);
              printf("Redirect[HttpRedirectCode]:%s\n", $routingRule['Redirect']['HttpRedirectCode']);
              printf("Redirect[HostName]:%s\n", $routingRule['Redirect']['HostName']);
       }
}catch (Obs\Common\ObsException $obsException){
       printf("ExceptionCode:%s\n", $obsException->getExceptionCode());              
       printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
}
分享:

    相关文档

    相关产品