尝试在下面的代码中解决一些问题。最终,我的问题是我无法找到以下MultiPartUpload过程的最新示例。与v3 PHP SDK相比,到目前为止我发现的所有内容都过时了。
在我看来,所有SDK看起来都是正确的,但是看起来“ UploadPartGenerator”方法不再存在。该函数存在时将返回部件,范围,校验和等,如下所示。
SDK缺少我的任何想法或信息来完成请求吗?
我必须手动计算零件,SHA256Treehashhes等吗?我觉得这应该还是SDK的一部分,而我只是在过时的信息之间缺少了一些东西。我发现的大多数与S3存储桶等有关。
就示例而言,我看不到冰川: https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/examples_index.html
在此先感谢您的帮助或信息!
require(__DIR__ . "/aws_sdk/aws-autoloader.php");
use Aws\Glacier\GlacierClient;
//use Aws\Glacier\TreeHash;
$key = '';
$secret = '';
$client = new GlacierClient(array(
'credentials' => array(
'key' => $key,
'secret' => $secret,
),
'profile' => 'default',
'region' => 'us-east-1',
'version' => '2012-06-01'
));
$filename = 'my_archive.zip';
$vaultName = 'test_vault';
/*
* Use helpers in the SDK to get information about each of the parts
*/
$archiveData = fopen($filename, 'r');
$partSize = 4 * 1024 * 1024; // (i.e., 4 MB)
/*
* This piece here is my main holdup -> UploadPartGenerator
*/
$parts = UploadPartGenerator::factory($archiveData, $partSize);
/*
* Initiate the upload and get the upload ID
*/
$result = $client->initiateMultipartUpload(array(
'vaultName' => $vaultName,
'partSize' => $partSize,
));
$uploadId = $result->get('uploadId');
/*
* Upload each part individually using data from the part generator
*/
foreach ($parts as $part) {
fseek($archiveData, $part->getOffset());
$client->uploadMultipartPart(array(
'vaultName' => $vaultName,
'uploadId' => $uploadId,
'body' => fread($archiveData, $part->getSize()),
'range' => $part->getFormattedRange(),
'checksum' => $part->getChecksum(),
'ContentSHA256' => $part->getContentHash(),
));
}
/*
* Complete the upload by using data aggregated by the part generator
*/
$result = $client->completeMultipartUpload(array(
'vaultName' => $vaultName,
'uploadId' => $uploadId,
'archiveSize' => $parts->getArchiveSize(),
'checksum' => $parts->getRootChecksum(),
));
$archiveId = $result->get('archiveId');
print($archiveId);
fclose($archiveData);