Skip to content

Commit 34f4361

Browse files
authored
update endpoint (#102)
1 parent bb003c3 commit 34f4361

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/Qcloud/Cos/BucketStyleListener.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ public function onCommandAfterPrepare(Event $event) {
5656
if ($this->ipport != null) {
5757
$request->setHost($this->ipport);
5858
$request->setHeader('Host', 'service.cos.myqcloud.com');
59-
} else {
59+
} else if ($this->endpoint != null) {
60+
$request->setHost($this->endpoint);
61+
$request->setHeader('Host', 'service.cos.myqcloud.com');
62+
}
63+
else {
6064

6165
$request->setHost('service.cos.myqcloud.com');
6266
}

src/Qcloud/Cos/Client.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class Client extends GSClient {
2525
private $schema;
2626
private $ip;
2727
private $port;
28+
private $config;
2829
public function __construct($config) {
30+
$this->config = $config;
2931
$this->region = $config['region'];
3032
$regionmap = array('cn-east'=>'ap-shanghai',
3133
'cn-south'=>'ap-guangzhou',
@@ -162,11 +164,10 @@ public function Copy($bucket, $key, $copysource, $options = array()) {
162164
$sourceregion = $sourcelistdot[2];
163165
$sourcekey = substr(strstr($copysource,'/'),1);
164166
$sourceversion = "";
165-
$cosClient = new Client(array('region' => $sourceregion,
166-
'credentials'=> array(
167-
'appId' => $sourceappid,
168-
'secretId' => $this->secretId,
169-
'secretKey' => $this->secretKey)));
167+
$sourceconfig = $this->config;
168+
$sourceconfig['region'] = $sourceregion;
169+
$sourceconfig['credentials']['appId'] = $sourceappid;
170+
$cosClient = new Client($sourceconfig);
170171
if (!key_exists('VersionId',$options['params'])) {
171172
$sourceversion = "";
172173
}

0 commit comments

Comments
 (0)