我正在尝试删除Amazon Glacier中的存档。我是通过PHP和PHP SDK2来做的。 我有一点问题..我已经找到了获得ArchiveID的工作:
$this->client->initiateJob(array(
'accountId' => '-',
'vaultName' => $aValutName,
'Type' => "inventory-retrieval")
);
几个小时后,我可以看到工作已经完成,所以我正在尝试使用它的ID获取工作:
$res = $this->client->getJobOutput(array(
'accountId' => '-',
'vaultName' => $aValutName,
'jobId' => $aJobID,
));
作为一种回应,我得到了这样的东西:
Guzzle\Service\Resource\Model Object
(
[structure:protected] =>
[data:protected] => Array
(
[body] => Guzzle\Http\EntityBody Object
(
[contentEncoding:protected] =>
[rewindFunction:protected] =>
[stream:protected] => Resource id #152
[size:protected] =>
[cache:protected] => Array
(
[wrapper_type] => PHP
[stream_type] => TEMP
[mode] => w+b
[unread_bytes] => 0
[seekable] => 1
[uri] => php://temp
[is_local] => 1
[is_readable] => 1
[is_writable] => 1
)
[customData:protected] => Array
(
[default] => 1
)
)
[checksum] =>
[status] => 200
[contentRange] =>
[acceptRanges] => bytes
[contentType] => application/json
[archiveDescription] =>
)
)
enybody想知道为什么“archiveDescription”是空的吗?
也许有另一种获取ArchiveID的方法,所以我可以删除我的档案....
Thanx任何帮助; D
MK。
答案 0 :(得分:0)
好的,解决方案太简单了......
public function getJobResult($aValutName, $aJobID) {
$res = $this->client->getJobOutput(array(
'accountId' => '-',
'vaultName' => $aValutName,
'jobId' => $aJobID,
));
$body = EntityBody::factory($res['body']);
$body->rewind();
$inventory = stream_get_contents($body->getStream());
$ArchiveList = json_decode($inventory,1)['ArchiveList'];
$res = array();
foreach($ArchiveList as $archive):
$res[]=$archive['ArchiveId'];
endforeach;
return $res;
}