Skip to content

Commit 0cf5fd9

Browse files
authored
Fix copy (#27)
* fix copy * fix partsize
1 parent 8819869 commit 0cf5fd9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Qcloud/Cos/Client.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ public function upload($bucket, $key, $body, $options = array()) {
119119
return $multipartUpload->performUploading();
120120
}
121121
public function copy($bucket, $key, $copysource, $options = array()) {
122+
122123
$options = Collection::fromConfig(array_change_key_case($options), array(
123-
'min_part_size' => MultipartUpload::MIN_PART_SIZE,
124+
'min_part_size' => Copy::MIN_PART_SIZE,
124125
'params' => $options));
125126
$sourcebucket = explode('-',explode('.',$copysource)[0])[0];
126127
$sourceappid = explode('-',explode('.',$copysource)[0])[1];
@@ -135,8 +136,9 @@ public function copy($bucket, $key, $copysource, $options = array()) {
135136
$rt = $cosClient->headObject(array('Bucket'=>$sourcebucket,
136137
'Key'=>$sourcekey));
137138
$contentlength =$rt['ContentLength'];
139+
138140
if ($contentlength < $options['min_part_size']) {
139-
return $this->UploadPartCopy(array(
141+
return $this->copyObject(array(
140142
'Bucket' => $bucket,
141143
'Key' => $key,
142144
'CopySource' => $copysource,

src/Qcloud/Cos/Copy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Copy {
88
/**
99
* const var: part size from 5MB to 5GB, and max parts of 10000 are allowed for each upload.
1010
*/
11-
const MIN_PART_SIZE = 5242880;
11+
const MIN_PART_SIZE = 52428800;
1212
const MAX_PART_SIZE = 5368709120;
1313
const MAX_PARTS = 10000;
1414

0 commit comments

Comments
 (0)