Skip to content

Commit 5d8177d

Browse files
authored
Fix copy (#28)
* fix copy * fix partsize * fix appid * fix .. // urldecode
1 parent 0cf5fd9 commit 5d8177d

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

src/Qcloud/Cos/BucketStyleListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function onCommandAfterPrepare(Event $event) {
5858
// Set the key and bucket on the request
5959
$request->getParams()->set('bucket', $bucket)->set('key', $key);
6060

61-
$request->setPath(urldecode($request->getPath()));
61+
//$request->setPath(urldecode($request->getPath()));
6262
// Switch to virtual hosted bucket
6363
$request->setHost($bucket. '.' . $request->getHost());
6464
if (!$bucket) {

src/Qcloud/Cos/Copy.php

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public function __construct($client, $contentlength, $source, $minPartSize, $opt
2727
}
2828

2929
public function performUploading() {
30+
31+
$commands = array();
32+
33+
34+
3035
$uploadId = $this->initiateMultipartUpload();
3136
$offset = 0;
3237
$partNumber = 1;
@@ -39,22 +44,39 @@ public function performUploading() {
3944
$partSize = $this->size - $offset -1;
4045
}
4146
//echo ('bytes='.( 'bytes='.((string)$offset).'-'.(string)($offset+$partSize)));
42-
$result = $this->client->UploadPartCopy(array(
43-
'Bucket' => $this->options['Bucket'],
44-
'Key' => $this->options['Key'],
45-
'UploadId' => $uploadId,
46-
'PartNumber' => $partNumber,
47-
'CopySource'=> $this->source,
48-
'CopySourceRange' => 'bytes='.((string)$offset).'-'.(string)($offset+$partSize)));
49-
$part = array('PartNumber' => $partNumber, 'ETag' => $result['ETag']);
50-
array_push($parts, $part);
47+
$commands[] = $this->client->getCommand('UploadPartCopy', array(
48+
'Bucket' => $this->options['Bucket'],
49+
'Key' => $this->options['Key'],
50+
'UploadId' => $uploadId,
51+
'PartNumber' => $partNumber,
52+
'CopySource'=> $this->source,
53+
'CopySourceRange' => 'bytes='.((string)$offset).'-'.(string)($offset+$partSize),
54+
));
55+
// $result = $this->client->UploadPartCopy(array(
56+
// 'Bucket' => $this->options['Bucket'],
57+
// 'Key' => $this->options['Key'],
58+
// 'UploadId' => $uploadId,
59+
// 'PartNumber' => $partNumber,
60+
// 'CopySource'=> $this->source,
61+
// 'CopySourceRange' => 'bytes='.((string)$offset).'-'.(string)($offset+$partSize)));
5162
++$partNumber;
5263
$offset += $partSize;
5364
if ($this->size == $offset+1)
5465
{
5566
break;
5667
}
5768
}
69+
$this->client->execute($commands);
70+
71+
72+
$partNumber = 1;
73+
foreach ($commands as $command) {
74+
75+
$result = $command->getResult();
76+
$part = array('PartNumber' => $partNumber, 'ETag' => $result['ETag']);
77+
array_push($parts, $part);
78+
$partNumber++;
79+
}
5880

5981
return $this->client->completeMultipartUpload(array(
6082
'Bucket' => $this->options['Bucket'],

0 commit comments

Comments
 (0)