Exemple #1
0
 public function init()
 {
     parent::init();
     if ($this->rootDirName) {
         $this->root = $this->rootDirName;
     }
 }
 /**
  * 初始化参数 
  * @example 
  *  new \yunke\upload\Oss('sales');
  * @param array|string $config
  */
 public function init()
 {
     parent::init();
     $this->bucket = Conf::fromCache('OSS_BUCKET') ? Conf::fromCache('OSS_BUCKET') : '';
     $this->domain = Conf::fromCache('OSS_ACCESS_URI') ? Conf::fromCache('OSS_ACCESS_URI') : '';
     //拼接文件返回地址的 http host部分
     $hostname = Conf::fromCache('OSS_HOST') ? Conf::fromCache('OSS_HOST') : '';
     //定义操作的指定节点hostname
     $OSS_ACCESS_ID = Conf::fromCache('OSS_ACCESS_KEY_ID') ? Conf::fromCache('OSS_ACCESS_KEY_ID') : '';
     $OSS_ACCESS_KEY = Conf::fromCache('OSS_ACCESS_KEY_SECRET') ? Conf::fromCache('OSS_ACCESS_KEY_SECRET') : '';
     if ($this->rootDirName) {
         $this->root = $this->rootDirName;
     }
     $this->oss = new \ALIOSS($OSS_ACCESS_ID, $OSS_ACCESS_KEY, $hostname);
 }
Exemple #3
0
 /**
  * 初始化参数 
  * @example 
  *  new \mysoft\upload\Oss('sales');
  * @param array|string $config
  */
 public function init()
 {
     parent::init();
     $oss = Conf::fromCache('oss');
     $oss = json_decode($oss, true);
     if (!is_array($oss)) {
         throw new \yii\base\InvalidConfigException('oss配置异常');
     }
     $this->bucket = isset($oss['oss_bucket']) ? $oss['oss_bucket'] : '';
     $this->domain = isset($oss['oss_access_uri']) ? $oss['oss_access_uri'] : '';
     //拼接文件返回地址的 http host部分
     $hostname = isset($oss['oss_host']) ? $oss['oss_host'] : '';
     //定义操作的指定节点hostname
     $OSS_ACCESS_ID = isset($oss['oss_access_key_id']) ? $oss['oss_access_key_id'] : '';
     //接入的ID
     $OSS_ACCESS_KEY = isset($oss['oss_access_key_secret']) ? $oss['oss_access_key_secret'] : '';
     //接入的密钥
     if ($this->rootDirName) {
         $this->root = $this->rootDirName;
     }
     $this->oss = new \ALIOSS($OSS_ACCESS_ID, $OSS_ACCESS_KEY, $hostname);
 }