$info = SCS::initiateMultipartUpload($bucket, $object, SCS::ACL_PUBLIC_READ); $uploadId = $info['upload_id']; $fp = fopen($file, 'rb'); $i = 1; $part_info = array(); while (!feof($fp)) { //上传分片 $res = SCS::putObject(SCS::inputResourceMultipart($fp, 1024 * 512, $uploadId, $i), $bucket, $object); if (isset($res['hash'])) { echo 'Part: ' . $i . " OK! \n"; $part_info[] = array('PartNumber' => $i, 'ETag' => $res['hash']); } $i++; } //列分片 $parts = SCS::listParts($bucket, $object, $uploadId); //print_r($parts); //print_r($part_info); if (count($parts) > 0 && count($parts) == count($part_info)) { foreach ($parts as $part_number => $part) { //echo $part['etag'] . "\n"; //echo $part_info[$k]['ETag'] . "\n"; if ($part['etag'] != $part_info[$part_number - 1]['ETag']) { exit('分片不匹配'); break; } } //合并分片 echo "开始合并\n"; SCS::completeMultipartUpload($bucket, $object, $uploadId, $part_info); echo "上传完成\n";