OSS\OssClient::__construct PHP Метод

__construct() публичный Метод

构造函数有几种情况: 1. 一般的时候初始化使用 $ossClient = new OssClient($id, $key, $endpoint) 2. 如果使用CNAME的,比如使用的是www.testoss.com,在控制台上做了CNAME的绑定, 初始化使用 $ossClient = new OssClient($id, $key, $endpoint, true) 3. 如果使用了阿里云SecurityTokenService(STS),获得了AccessKeyID, AccessKeySecret, Token 初始化使用 $ossClient = new OssClient($id, $key, $endpoint, false, $token) 4. 如果用户使用的endpoint是ip 初始化使用 $ossClient = new OssClient($id, $key, “1.2.3.4:8900”)
public __construct ( string $accessKeyId, string $accessKeySecret, string $endpoint, boolean $isCName = false, string $securityToken = NULL )
$accessKeyId string 从OSS获得的AccessKeyId
$accessKeySecret string 从OSS获得的AccessKeySecret
$endpoint string 您选定的OSS数据中心访问域名,例如oss-cn-hangzhou.aliyuncs.com
$isCName boolean 是否对Bucket做了域名绑定,并且Endpoint参数填写的是自己的域名
$securityToken string
    public function __construct($accessKeyId, $accessKeySecret, $endpoint, $isCName = false, $securityToken = NULL)
    {
        $accessKeyId = trim($accessKeyId);
        $accessKeySecret = trim($accessKeySecret);
        $endpoint = trim(trim($endpoint), "/");
        if (empty($accessKeyId)) {
            throw new OssException("access key id is empty");
        }
        if (empty($accessKeySecret)) {
            throw new OssException("access key secret is empty");
        }
        if (empty($endpoint)) {
            throw new OssException("endpoint is empty");
        }
        $this->hostname = $this->checkEndpoint($endpoint, $isCName);
        $this->accessKeyId = $accessKeyId;
        $this->accessKeySecret = $accessKeySecret;
        $this->securityToken = $securityToken;
        self::checkEnv();
    }

Usage Example

Пример #1
0
 /**
  * @inheritDoc
  */
 public function __construct($accessKeyId, $accessKeySecret, $endpoint, $isCName, $securityToken)
 {
     parent::__construct($accessKeyId, $accessKeySecret, $endpoint, $isCName, $securityToken);
 }