ak) && $this->ak = $config['qiniu_ak']; empty($this->sk) && $this->sk = $config['qiniu_sk']; empty($this->bucket) && $this->bucket = $config['qiniu_bucket']; empty($this->domain) && $this->domain = $config['qiniu_domain']; } // 上传文件 public function putFile($key, $filePath) { $token = $this->getToken(); $uploadMgr = new UploadManager(); list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath); if ($err !== null) { return false; } else { return $this->domain . $ret['key']; } } // 删除远程文件 public function delete($key) { $auth = new Auth($this->ak, $this->sk); $config = new Config(); $bucketManager = new BucketManager($auth, $config); $bucketManager->delete($this->bucket, $key); } // 获取token protected function getToken() { $auth = new Auth($this->ak, $this->sk); $token = $auth->uploadToken($this->bucket); return $token; } }