0

我正在尝试删除我在 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] => 
        )

)

有人知道为什么“archiveDescription”是空的吗?

也许还有另一种获取 ArchiveID 的方法,这样我就可以删除我的存档....

感谢任何帮助;D

MK。

4

1 回答 1

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;
}
于 2013-11-15T09:01:45.297 回答