创建空间
@param string $bucket Bucket名称
@param string $acl ACL权限[OSS\OssClient\OssClient::OSS_ACL_TYPE_PRIVATE、OSS\OssClient\OssClient::OSS_ACL_TYPE_PUBLIC_READ、OSS\OssClient\OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE]
@return array
427024
public function createBucket(string $bucket, string $acl = OssClient::OSS_ACL_TYPE_PRIVATE)
    {
        try {
            $this->client->createBucket($bucket, $acl);
            return $this->success('创建Bucket成功');
        } catch (\Exception $exception) {
            return $this->error('调用阿里云接口出错：' . $exception->getMessage());
        }
    }
1025063
public function list_object($bucket, $opt = array()) {
		$this->assertParameterArray ( $opt );
		$opt [self::BUCKET] = $bucket;
		if (empty ( $opt [self::BUCKET] )) {
			throw new BCS_Exception ( "Bucket should not be empty, please check", - 1 );
		}
		$opt [self::METHOD] = 'GET';
		$opt [self::OBJECT] = '/';
		$opt [self::QUERY_STRING] = array ();
		if (isset ( $opt ['start'] ) && is_int ( $opt ['start'] )) {
			$opt [self::QUERY_STRING] ['start'] = $opt ['start'];
		}
		if (isset ( $opt ['limit'] ) && is_int ( $opt ['limit'] )) {
			$opt [self::QUERY_STRING] ['limit'] = $opt ['limit'];
		}
		if (isset ( $opt ['prefix'] )) {
			$opt [self::QUERY_STRING] ['prefix'] = rawurlencode ( $opt ['prefix'] );
		}
		$response = $this->authenticate ( $opt );
		$this->log ( $response->isOK () ? "List object success!" : "Lit object failed! Response: [" . $response->body . "]", $opt );
		return $response;
	}
1100966
public static function hydrate(stdClass $acl)
    {
        $hydrated = new AclEntity();

        if (isset($acl->id)) {
            $hydrated->setId($acl->id);
        }

        if (isset($acl->owner_user)) {
            $hydrated->setOwnerUser(UserHydrator::hydrate($acl->owner_user));
        }

        if (isset($acl->owner_team)) {
            $hydrated->setOwnerTeam(TeamHydrator::hydrate($acl->owner_team));
        }

        if (isset($acl->application)) {
            $hydrated->setApplication(ApplicationHydrator::hydrate($acl->application));
        }

        if (isset($acl->created_by)) {
            $hydrated->setCreatedBy(UserHydrator::hydrate($acl->created_by));
        }

        if (isset($acl->view)) {
            $hydrated->setView($acl->view);
        }

        if (isset($acl->delete)) {
            $hydrated->setDelete($acl->delete);
        }

        if (isset($acl->create)) {
            $hydrated->setCreate($acl->create);
        }

        if (isset($acl->edit)) {
            $hydrated->setEdit($acl->edit);
        }

        if (isset($acl->scan)) {
            $hydrated->setScan($acl->scan);
        }

        if (isset($acl->manage)) {
            $hydrated->setManage($acl->manage);
        }

        if (isset($acl->immutable)) {
            $hydrated->setImmutable($acl->immutable);
        }

        return $hydrated;
    }
442630
def get(self, acl):
        
        return self._instance._client.acls.get(self._instance.name, acl)
494957
public function bucketDestroy($bucket)
    {
        $oBucket = $this->getBucket($bucket);

        if (!$oBucket) {
            $this->setError('Not a valid bucket');
            return false;
        }

        // --------------------------------------------------------------------------

        //  Destroy any containing objects
        $errors = 0;
        foreach ($oBucket->objects as $obj) {
            if (!$this->objectDestroy($obj->id)) {
                $this->setError('Unable to delete object "' . $obj->file->name->human . '" (ID:' . $obj->id . ').');
                $errors++;
            }
        }

        if ($errors) {

            $this->setError('Unable to delete bucket, bucket not empty.');
            return false;

        } else {

            if ($this->callDriver('bucketDestroy', [$oBucket->slug])) {

                $oDb = Factory::service('Database');
                $oDb->where('id', $oBucket->id);
                $oDb->delete(NAILS_DB_PREFIX . 'cdn_bucket');
                return true;

            } else {

                $this->setError('Unable to remove empty bucket directory. ' . $this->callDriver('lastError'));
                return false;
            }
        }
    }
858896
private function getMaskAtIndex(AclInterface $acl, $index)
    {
        $objectAces = $acl->getObjectAces();
        /* @var $ace AuditableEntryInterface */
        $ace = $objectAces[$index];
        $securityIdentity = $ace->getSecurityIdentity();
        if ($securityIdentity instanceof RoleSecurityIdentity) {
            return $ace->getMask();
        }

        return false;
    }
985806
public function getAcl() {
        $options = $this->getOptions();
        if ($this->_acl === null) {
            $this->_acl = Zend_Registry::isRegistered(self::DEFAULT_REGISTRY_KEY) ?
                Zend_Registry::get(self::DEFAULT_REGISTRY_KEY) : new Zend_Acl();


            $roles = array();
            $resources = array();

            if (isset($options['roles'])) {
                $roles = $options['roles'];
            }

            if (isset($options['resources'])) {
                $resources = $options['resources'];
            }

            $this->_addRoles($roles);
            $this->_addResources($resources);
        }

        return $this->_acl;
    }
419545
public static function delFile($bucket, $path) {
        if (empty($bucket) || empty($path)) {
            return array(
                    'code' => COSAPI_PARAMS_ERROR,
                    'message' => 'path is empty');
        }

        $path = self::normalizerPath($path);

        return self::delBase($bucket, $path);
    }
928086
public function listObjects($bucket, $marker = null, $maxKeys = 10, $delimiter = '', $prefix = '')
    {
        try {
            $options = [];
            $marker && $options['marker'] = $marker;
            $delimiter && $options['delimiter'] = $delimiter;
            $maxKeys && $options['max-keys'] = $maxKeys;
            $prefix && $options['prefix'] = $prefix;
            $objects = $this->client->listObjects($bucket, $options)->getObjectList();
            return $this->success('获取成功', ['objects' => $objects]);
        } catch (\Exception $exception) {
            return $this->error('调用阿里云接口出错：' . $exception->getMessage());
        }
    }
695210
public function putACLRequest($options=array())
    {
        $operation = array(
            'API' => 'PutBucketACL',
            'Method' => 'PUT',
            'Uri' => '/<bucket-name>?acl',
            'Headers' => array(
                'Host' => $this->properties['zone'] . '.' . $this->config->host,
            ),
            'Params' => array(
            ),
            'Elements' => array(
                'acl' => isset($options['acl'])?$options['acl']:null,
            ),
            'Properties' => $this->properties,
            'Body' => null
        );
        $this->putACLValidate($operation);
        $req = new Request($this->config, $operation);
        return $req;
    }
523668
public function getObject(string $bucket, string $object)
    {
        try {
            $content = $this->client->getObject($bucket, $object);
            return $this->success('获取文件成功', ['object' => $content]);
        } catch (\Exception $exception) {
            return $this->error('调用阿里云接口出错：' . $exception->getMessage());
        }
    }
1240862
public function toSddl($canonicalize = true)
    {
        // These will always be present in the SDDL...
        $sddl = 'O:'.($this->owner->getShortName() ?: $this->owner).'G:'.($this->group->getShortName() ?: $this->group);

        foreach ([$this->dacl, $this->sacl] as $acl) {
            // It should be omitted if empty or not set...
            if ($acl && count($acl->getAces()) > 0) {
                $sddl .= $acl->getSddlIdentifier().':'.$this->getAclSddlFlags($acl);
                $sddl .= $acl instanceof Dacl ? $acl->toSddl($canonicalize) : $acl->toSddl();
            }
        }

        return $sddl;
    }
761063
public function createBucket($bucket, $acl = self::OSS_ACL_TYPE_PRIVATE, $options = NULL)
    {
        $this->precheckCommon($bucket, NULL, $options, false);
        $options[self::OSS_BUCKET] = $bucket;
        $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
        $options[self::OSS_OBJECT] = '/';
        $options[self::OSS_HEADERS] = array(self::OSS_ACL => $acl);
        if (isset($options[self::OSS_STORAGE])) {
            $this->precheckStorage($options[self::OSS_STORAGE]);
            $options[self::OSS_CONTENT] = OssUtil::createBucketXmlBody($options[self::OSS_STORAGE]);
            unset($options[self::OSS_STORAGE]);
        }
        $response = $this->auth($options);
        $result = new PutSetDeleteResult($response);
        return $result->getData();
    }
1021059
protected function getObjectACL($path)
    {
        $metadata = $this->getVisibility($path);

        return $metadata['visibility'] === AdapterInterface::VISIBILITY_PUBLIC ? OssClient::OSS_ACL_TYPE_PUBLIC_READ : OssClient::OSS_ACL_TYPE_PRIVATE;
    }
259860
public static function createBucket()
    {
        $ossClient = self::getOssClient();
        if (is_null($ossClient)) exit(1);
        $bucket = self::getBucketName();
        $acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ;
        try {
            $ossClient->createBucket($bucket, $acl);
        } catch (OssException $e) {

            $message = $e->getMessage();
            if (\OSS\Core\OssUtil::startsWith($message, 'http status: 403')) {
                echo "Please Check your AccessKeyId and AccessKeySecret" . "\n";
                exit(0);
            } elseif (strpos($message, "BucketAlreadyExists") !== false) {
                echo "Bucket already exists. Please check whether the bucket belongs to you, or it was visited with correct endpoint. " . "\n";
                exit(0);
            }
            printf(__FUNCTION__ . ": FAILED\n");
            printf($e->getMessage() . "\n");
            return;
        }
        print(__FUNCTION__ . ": OK" . "\n");
    }
372821
public function count($bucket){
        $amount = 0;
        $flag = true;
        $marker = '';
        while ($flag){
            $response = $this->listFiles($bucket, 1000, '', $marker);
            if(!$response['success']){
                return $response;
            }
            $marker = isset($response['data']['marker']) ? $response['data']['marker'] : '';
            $items = $response['data']['items'];
            $amount += count($items);
            if(!$marker){
                $flag = false;
            }
        }
        return $this->success('操作成功', ['amount'=>$amount]);
    }
328882
public function getContextualAcl()
    {
        $acl = $this->getRules();
        if (!$acl->hasRole($this->getContextId())) {
            $contextRoles = $this->getContext()->getRoles();
            if ($contextRoles instanceof RoleBucket) {
                $contextRoles = $contextRoles->toArray();
            }
            $acl->addRole(new Role($this->getContextId()), $contextRoles);
        }
        return $acl;
    }