cosClient = new CosClient( [ 'region' => $this->region, 'credentials' => [ 'appId' => $this->appId, 'secretId' => $this->accessKey, 'secretKey' => $this->secretKey, ], ] ); } public function put($localFile, $saveTo) { $handle = fopen($localFile, 'rb'); try { $saveTo = ltrim($saveTo, '/'); $res = $this->cosClient->putObject( [ 'Bucket' => $this->bucket, 'Key' => $saveTo, 'Body' => $handle, ] ); } catch (\Exception $ex) { throw new StorageException($ex->getMessage()); } return $res->offsetGet('Location'); } }