exit("\nERROR: SCS access information required\n\nPlease edit the following lines in this file:\n\n" . "define('AccessKey', 'change-me');\ndefine('SecretKey', 'change-me');\n\n"); } // Pointless without your BucketName! if (BucketName == 'change-this') { exit("\nERROR: BucketName required\n\nPlease edit the following lines in this file:\n\n" . "define('BucketName', 'change-me');\n\n"); } SCS::setAuth(AccessKey, SecretKey); $bucket = BucketName; ################################################################################ $object = "path/to/my/Sublime Text 2.0.2.dmg"; $file = "/Users/caoli/Downloads/Sublime Text 2.0.2.dmg"; $fp = fopen($file, 'rb'); SCS::setExceptions(true); try { //初始化上传 $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);