Skip to content

Commit 4795d8e

Browse files
authored
Fix v4 (#38)
* update v4 * md5 check * fix appid
1 parent b8131bf commit 4795d8e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Qcloud/Cos/Client.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Qcloud\Cos;
44

5+
use Guzzle\Service\Description\Parameter;
56
use Guzzle\Service\Description\ServiceDescription;
67
use Guzzle\Service\Client as GSClient;
78
use Guzzle\Common\Collection;
@@ -126,28 +127,35 @@ public function copy($bucket, $key, $copysource, $options = array()) {
126127
$sourceappid = explode('-',explode('.',$copysource)[0])[1];
127128
$sourceregion = explode('.',$copysource)[2];
128129
$sourcekey = substr(strstr($copysource,'/'),1);
130+
$sourceversion = "";
129131
$cosClient = new Client(array('region' => $sourceregion,
130132
'credentials'=> array(
131133
'appId' => $sourceappid,
132134
'secretId' => $this->secretId,
133135
'secretKey' => $this->secretKey)));
134-
$rt = $cosClient->headObject(array('Bucket'=>$sourcebucket,
136+
if (!key_exists('VersionId',$options['params'])) {
137+
$sourceversion = "";
138+
}
139+
else{
140+
$sourceversion = $options['params']['VersionId'];
141+
}
142+
$rt = $cosClient->headObject(array('Bucket'=>$sourcebucket,
135143
'Key'=>$sourcekey,
136-
'VersionId'=>$options['params']['VersionId']));
144+
'VersionId'=>$sourceversion));
137145
$contentlength =$rt['ContentLength'];
138146

139147
if ($contentlength < $options['min_part_size']) {
140148
return $this->copyObject(array(
141149
'Bucket' => $bucket,
142150
'Key' => $key,
143-
'CopySource' => $copysource."?versionId=".$options['params']['VersionId'],
151+
'CopySource' => $copysource."?versionId=".$sourceversion,
144152
) + $options['params']);
145153
}
146154
$copy = new Copy($this, $contentlength, $copysource, $options['min_part_size'], array(
147155
'Bucket' => $bucket,
148156
'Key' => $key,
149157
'ContentLength' => $contentlength,
150-
'CopySource' => $copysource."?versionId=".$options['params']['VersionId'],
158+
'CopySource' => $copysource."?versionId=".$sourceversion,
151159
) + $options['params']);
152160

153161
return $copy->performUploading();

src/Qcloud/Cos/MultipartUpload.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public function performUploading() {
5353
array_push($parts, $part);
5454
++$partNumber;
5555
}
56-
5756
return $this->client->completeMultipartUpload(array(
5857
'Bucket' => $this->options['Bucket'],
5958
'Key' => $this->options['Key'],

0 commit comments

Comments
 (0)