设置 Bucket 访问权限

@param String $bucket 空间名称
@param integer $private 权限 0 公开 1 私有

@return Mixed
@link https://developer.qiniu.com/kodo/api/3946/put-bucket-acl
970918
public function setBucketAuth($bucket, $private)
    {
        $path = "/private";
        $params = "bucket=".$bucket."&private=".$private;
        list(, $error) = $this->ucPost($path, $params);
        return $error;
    }
405867
public function getObject($bucket, $key, array $params = [])
    {
        $params['Bucket'] = $bucket;
        $params['Key'] = $key;

        return $this->instance->getObject($params);
    }
323361
public function encryptPrivateKey($privateKey, $password)
    {
        try {
            return CryptoVirgilKeyPair::encryptPrivateKey($privateKey, $password);
        } catch (Exception $exception) {
            throw new PrivateKeyEncryptionException($exception->getMessage(), $exception->getCode());
        }
    }
738469
def get_bucket_acl(self, bucket):
        
        details = self._details(
            method=b"GET",
            url_context=self._url_context(bucket=bucket, object_name="?acl"),
        )
        d = self._submit(self._query_factory(details))
        d.addCallback(self._parse_acl)
        return d
216707
public function stat($bucket, $key){
        list($fileInfo, $err) = $this->bucketManager->stat($bucket, $key);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功', $fileInfo);
    }
1353108
public function getObjectAcl($bucket, $key)
    {
        $params = [
            'Bucket' => $bucket,
            'Key'    => $key
        ];

        return $this->instance->getObjectAcl($params);
    }
1318391
public function delete($bucket, $key)
    {
        $path = '/delete/' . \Qiniu\entry($bucket, $key);
        list(, $error) = $this->rsPost($path);
        return $error;
    }
979023
public function dropBucket($bucket){
        $err = $this->subBucketManager->dropBucket($bucket);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功');
    }
980119
private function delBase($bucket, $path)
    {
        if ($path == "/") {
            return [
                'code'      => Response::COSAPI_PARAMS_ERROR,
                'message'   => 'can not delete bucket using api! go to ' .
                    'http://console.qcloud.com/cos to operate bucket'
            ];
        }

        $path       = self::cosUrlEncode($path);
        $url        = self::generateResUrl($bucket, $path);
        $signature  = $this->createNonreusableSignature($bucket, $path);
        $data       = ['op' => 'delete'];
        $data       = json_encode($data);

        $req = [
            'url'       => $url,
            'method'    => 'post',
            'timeout'   => self::$timeout,
            'data'      => $data,
            'header'    => [
                'Authorization: ' . $signature,
                'Content-Type: application/json',
            ],
        ];

        return self::sendRequest($req);
    }
38066
private function getBucket($time = null)
    {
        $time = $time ?: time();

        return (int) floor(($time % $this->bucketSpan) / $this->bucketInterval);
    }
803876
private static function delBase($bucket, $path) {
        if ($path == "/") {
            return array(
                    'code' => COSAPI_PARAMS_ERROR,
                    'message' => 'can not delete bucket using api! go to ' .
                                 'http://console.qcloud.com/cos to operate bucket');
        }

        $path = self::cosUrlEncode($path);
        $expired = time() + self::EXPIRED_SECONDS;
        $url = self::generateResUrl($bucket, $path);
        $signature = Auth::createNonreusableSignature($bucket, $path);

        $data = array('op' => 'delete');

        $data = json_encode($data);

        $req = array(
            'url' => $url,
            'method' => 'post',
            'timeout' => self::$timeout,
            'data' => $data,
            'header' => array(
                'Authorization: ' . $signature,
                'Content-Type: application/json',
            ),
        );

        return self::sendRequest($req);
    }
487723
public function getAllZip($bucketName, array $filesName, $zipFileName, $private = false){
        $zip = new \ZipArchive();
        if ($zip->open($zipFileName, \ZipArchive::CREATE) === true) {
            foreach ($filesName as $file) {
                $content = $this->get($bucketName,$file,$private,false);
                if($content !== false){
                    try{
                        $zip->addFromString($file, $content["content"]);
                    }catch (\Exception $e){
                        return false;
                    }
                }
            }
            $zip->close();
        }else{
            return false;
        }
        return true;
    }
1011409
public Acl updateBucketAcl(String bucketName) {
    // [START updateBucketAcl]
    Acl acl = storage.updateAcl(bucketName, Acl.of(User.ofAllAuthenticatedUsers(), Role.OWNER));
    // [END updateBucketAcl]
    return acl;
  }
1003673
public static function setAccessControlPolicy($bucket, $uri = '', $acp = array())
	{
		$dom = new DOMDocument;
		$dom->formatOutput = true;
		$accessControlPolicy = $dom->createElement('AccessControlPolicy');
		$accessControlList = $dom->createElement('AccessControlList');

		// It seems the owner has to be passed along too
		$owner = $dom->createElement('Owner');
		$owner->appendChild($dom->createElement('ID', $acp['owner']['id']));
		$owner->appendChild($dom->createElement('DisplayName', $acp['owner']['name']));
		$accessControlPolicy->appendChild($owner);

		foreach ($acp['acl'] as $g)
		{
			$grant = $dom->createElement('Grant');
			$grantee = $dom->createElement('Grantee');
			$grantee->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
			if (isset($g['id']))
			{ // CanonicalUser (DisplayName is omitted)
				$grantee->setAttribute('xsi:type', 'CanonicalUser');
				$grantee->appendChild($dom->createElement('ID', $g['id']));
			}
			elseif (isset($g['email']))
			{ // AmazonCustomerByEmail
				$grantee->setAttribute('xsi:type', 'AmazonCustomerByEmail');
				$grantee->appendChild($dom->createElement('EmailAddress', $g['email']));
			}
			elseif ($g['type'] == 'Group')
			{ // Group
				$grantee->setAttribute('xsi:type', 'Group');
				$grantee->appendChild($dom->createElement('URI', $g['uri']));
			}
			$grant->appendChild($grantee);
			$grant->appendChild($dom->createElement('Permission', $g['permission']));
			$accessControlList->appendChild($grant);
		}

		$accessControlPolicy->appendChild($accessControlList);
		$dom->appendChild($accessControlPolicy);

		$rest = new S3Request('PUT', $bucket, $uri, self::$endpoint);
		$rest->setParameter('acl', null);
		$rest->data = $dom->saveXML();
		$rest->size = strlen($rest->data);
		$rest->setHeader('Content-Type', 'application/xml');
		$rest = $rest->getResponse();
		if ($rest->error === false && $rest->code !== 200)
			$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
		if ($rest->error !== false)
		{
			self::__triggerError(sprintf("S3::setAccessControlPolicy({$bucket}, {$uri}): [%s] %s",
			$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
			return false;
		}
		return true;
	}
577555
public Acl createDefaultBucketAcl(String bucketName) {
    // [START createDefaultBucketAcl]
    Acl acl =
        storage.createDefaultAcl(bucketName, Acl.of(User.ofAllAuthenticatedUsers(), Role.READER));
    // [END createDefaultBucketAcl]
    return acl;
  }
1359847
public function move($srcBucket, $srcKey, $destBucket, $destKey, $force=true){
        $err = $this->bucketManager->move($srcBucket, $srcKey, $destBucket, $destKey, $force);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功');
    }
14714
public function get_bucket_acl($bucket, $opt = array()) {
		$this->assertParameterArray ( $opt );
		$opt [self::BUCKET] = $bucket;
		$opt [self::METHOD] = 'GET';
		$opt [self::OBJECT] = '/';
		$opt [self::QUERY_STRING] = array (
				self::ACL => 1 );
		$response = $this->authenticate ( $opt );
		$this->log ( $response->isOK () ? "Get bucket acl success!" : "Get bucket acl failed! Response: [" . $response->body . "]", $opt );
		return $response;
	}