| Bucket接口 > 设置 Bucket 访问权限 | |||||||||
|
| 参数名称 | 必填 | 说明 |
|---|---|---|
| bucket | 是 | 空间名称 |
| private | 是 | 0 公开 1 私有 |
该请求操作的实现使用了所有操作的公共请求头。
该请求操作的实现使用了所有操作的公共响应头。
该请求操作的响应体为空。
该操作的实现不会返回特殊错误。
请求示例:
POST /private HTTP/1.1 Host: uc.qbox.me User-Agent: Go-http-client/1.1 Content-Length: 23 Authorization: QBox j853F3bLkWl59I5BOkWm6q1Z1mZClpr9Z9CLfDE0:YHLW5tnhbumBI56iQ0AzJdZONSY= Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip bucket=test&private=1
HTTP/1.1 200 OK
Content-Length: 2
Connection: keep-alive
Content-Type: application/json
Date: Thu, 17 Aug 2017 10:01:01 GMT
Server: nginx
X-Reqid: VBoAAJjbI4_ZmdsU
{}functon updatePrivate($accessKey, $secretKey, $bucket, $private)
{
$authObj = new Auth($accessKey, $secretKey);
$http = new Http();
$url = "http://uc.qbox.me/private";
$body = "bucket={$bucket}&private={$private}";
$headers = $authObj->getHeaders($url, $body, 'application/x-www-form-urlencoded');
// 创建一个新cURL资源
$curl = curl_init();
// 设置URL和相应的选项
curl_setopt($curl, CURLOPT_URL, $url);
//CURLOPT_HEADER为true设置头文件的信息作为数据流输出
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper('POST'));
curl_setopt($curl, CURLOPT_POST, true);
$updatePrivate = curl_exec($curl);
curl_close($curl);
return $updatePrivate;
}
$accessKey = 'xxx';
$secretKey = 'xxx';
$bucket = '123_1';//空间名称
$private = 1;//0公有 1私有
echo $updatePrivate($accessKey, $secretKey, $bucket, $private);