diff --git a/src/Qcloud/Cos/BucketStyleListener.php b/src/Qcloud/Cos/BucketStyleListener.php index c1c0fd1e..b1bd5667 100644 --- a/src/Qcloud/Cos/BucketStyleListener.php +++ b/src/Qcloud/Cos/BucketStyleListener.php @@ -56,7 +56,11 @@ public function onCommandAfterPrepare(Event $event) { if ($this->ipport != null) { $request->setHost($this->ipport); $request->setHeader('Host', 'service.cos.myqcloud.com'); - } else { + } else if ($this->endpoint != null) { + $request->setHost($this->endpoint); + $request->setHeader('Host', 'service.cos.myqcloud.com'); + } + else { $request->setHost('service.cos.myqcloud.com'); } diff --git a/src/Qcloud/Cos/Client.php b/src/Qcloud/Cos/Client.php index a397a192..171ea457 100644 --- a/src/Qcloud/Cos/Client.php +++ b/src/Qcloud/Cos/Client.php @@ -25,7 +25,9 @@ class Client extends GSClient { private $schema; private $ip; private $port; + private $config; public function __construct($config) { + $this->config = $config; $this->region = $config['region']; $regionmap = array('cn-east'=>'ap-shanghai', 'cn-south'=>'ap-guangzhou', @@ -162,11 +164,10 @@ public function Copy($bucket, $key, $copysource, $options = array()) { $sourceregion = $sourcelistdot[2]; $sourcekey = substr(strstr($copysource,'/'),1); $sourceversion = ""; - $cosClient = new Client(array('region' => $sourceregion, - 'credentials'=> array( - 'appId' => $sourceappid, - 'secretId' => $this->secretId, - 'secretKey' => $this->secretKey))); + $sourceconfig = $this->config; + $sourceconfig['region'] = $sourceregion; + $sourceconfig['credentials']['appId'] = $sourceappid; + $cosClient = new Client($sourceconfig); if (!key_exists('VersionId',$options['params'])) { $sourceversion = ""; }