|
2 | 2 |
|
3 | 3 | namespace Qcloud\Cos; |
4 | 4 |
|
| 5 | +use Guzzle\Service\Description\Parameter; |
5 | 6 | use Guzzle\Service\Description\ServiceDescription; |
6 | 7 | use Guzzle\Service\Client as GSClient; |
7 | 8 | use Guzzle\Common\Collection; |
@@ -126,28 +127,35 @@ public function copy($bucket, $key, $copysource, $options = array()) { |
126 | 127 | $sourceappid = explode('-',explode('.',$copysource)[0])[1]; |
127 | 128 | $sourceregion = explode('.',$copysource)[2]; |
128 | 129 | $sourcekey = substr(strstr($copysource,'/'),1); |
| 130 | + $sourceversion = ""; |
129 | 131 | $cosClient = new Client(array('region' => $sourceregion, |
130 | 132 | 'credentials'=> array( |
131 | 133 | 'appId' => $sourceappid, |
132 | 134 | 'secretId' => $this->secretId, |
133 | 135 | '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, |
135 | 143 | 'Key'=>$sourcekey, |
136 | | - 'VersionId'=>$options['params']['VersionId'])); |
| 144 | + 'VersionId'=>$sourceversion)); |
137 | 145 | $contentlength =$rt['ContentLength']; |
138 | 146 |
|
139 | 147 | if ($contentlength < $options['min_part_size']) { |
140 | 148 | return $this->copyObject(array( |
141 | 149 | 'Bucket' => $bucket, |
142 | 150 | 'Key' => $key, |
143 | | - 'CopySource' => $copysource."?versionId=".$options['params']['VersionId'], |
| 151 | + 'CopySource' => $copysource."?versionId=".$sourceversion, |
144 | 152 | ) + $options['params']); |
145 | 153 | } |
146 | 154 | $copy = new Copy($this, $contentlength, $copysource, $options['min_part_size'], array( |
147 | 155 | 'Bucket' => $bucket, |
148 | 156 | 'Key' => $key, |
149 | 157 | 'ContentLength' => $contentlength, |
150 | | - 'CopySource' => $copysource."?versionId=".$options['params']['VersionId'], |
| 158 | + 'CopySource' => $copysource."?versionId=".$sourceversion, |
151 | 159 | ) + $options['params']); |
152 | 160 |
|
153 | 161 | return $copy->performUploading(); |
|
0 commit comments