'upload.qiniup.com', // 华东 2 => 'upload-z1.qiniup.com', // 华北区 3 => 'upload-z2.qiniup.com', // 华南区 4 => 'upload-na0.qiniup.com', // 北美区 5 => 'upload-as0.qiniup.com', // 东南亚区 ]; /** * 直传 token * * @return array */ public function config() { $config = $this->config; $accessKey = $config['storage_qiniu_accesskey']; $secretKey = $config['storage_qiniu_secrectkey']; $host = $config['storage_qiniu_host']; $auth = new Auth($accessKey, $secretKey); $bucket = $config['storage_qiniu_bucket']; // 生成上传Token $token = $auth->uploadToken($bucket); return [ 'token' => $token, 'x:host' => $this->host_area[$host], ]; } /** * @param $baseInfo * @param $fullPath */ protected function baseUrl($baseInfo, $fullPath) { $this->filesystem->addPlugin(new FileUrl()); $baseInfo['url'] = $this->filesystem->getUrl($baseInfo['url']); return $baseInfo; } /** * @param $baseInfo * @param $fullPath */ protected function domainName($baseInfo, $fullPath) { $this->filesystem->addPlugin(new FileUrl()); $baseInfo['domain_name'] = $this->filesystem->getUrl($baseInfo['domain_name']); return $baseInfo; } /** * @return mixed|void * @throws \Exception */ protected function create() { $config = $this->config; $accessKey = $config['access_key_id']; $secretKey = $config['access_key_secret']; $cdnHost = $config['domain']; $bucket = $config['bucket']; $this->adapter = new QiniuAdapter($accessKey, $secretKey, $bucket, $cdnHost); } }