无法使用 php 从 Amazon Glacier 下载存档文件
Cannot download archived files from Amazon Glacier using php
我正在尝试从 amazon glacier 下载文件。我已经开始了我的工作并成功获得了我的 jobId。
现在我正在使用下面的代码下载我存档的上传文件,但我看到了这个回复
object(Aws\Result)#129 (2) {
["data":"Aws\Result":private]=> array(8) {
["body"]=> object(GuzzleHttp\Psr7\Stream)#114 (7) {
{"stream":"GuzzleHttp\Psr7\Stream":private]=> resource(118) of type (stream)
["size":"GuzzleHttp\Psr7\Stream":private]=> NULL
["seekable":"GuzzleHttp\Psr7\Stream":private]=> bool(true)
["readable":"GuzzleHttp\Psr7\Stream":private]=> bool(true)
["writable":"GuzzleHttp\Psr7\Stream":private]=> bool(true)
["uri":"GuzzleHttp\Psr7\Stream":private]=> string(10) "php://temp"
["customMetadata":"GuzzleHttp\Psr7\Stream":private]=> array(0) { } }
["checksum"]=> string(0) ""
["status"]=> int(200)
["contentRange"]=> string(0) ""
["acceptRanges"]=> string(5) "bytes"
["contentType"]=> string(16) "application/json"
["archiveDescription"]=> string(0) ""
["@metadata"]=> array(4) {
["statusCode"]=> int(200)
["effectiveUri"]=> string(161) "https://glacier.us-east-2.amazonaws.com/-/vaults/myvault/jobs/my-jobid-removed-for-privacy/output"
["headers"]=> array(5) {
["x-amzn-requestid"]=> string(47) "AXVtTY2JMZzODN_Yya2c"
["accept-ranges"]=> string(5) "bytes"
["content-type"]=> string(16) "application/json"
["content-length"]=> string(3) "124"
["date"]=> string(29) "Thu, 15 Aug 2019 14:51:40 GMT"
}
["transferStats"]=> array(1) {
["http"]=> array(1) {
[0]=> array(0) { }
}
}
}
}
["monitoringEvents":"Aws\Result":private]=> array(0) { }
}
我需要设置什么权限吗。我的存档文件是私有的。谁能告诉我一些事情
这里是代码
require 'vendor/autoload.php';
use Aws\Glacier\GlacierClient;
use Aws\Glacier\TreeHash;
$client = new GlacierClient([
'version' => 'latest',
'region' => 'my-region',
'credentials' => [
'key' => 'my key',
'secret' => 'my secret'
]
]);
$result = $client->getJobOutput([
'accountId' => '-',
'jobId' => 'my job id',
'vaultName' => 'my valt name here',
]);
var_dump($result);
echo $data = $result->get('body');
不要忘记 Glacier 中的文件需要一些时间才能 "unfreeze" 变得可下载和可用。这就是 Glacier 比 S3 这样的东西便宜得多的确切原因。
Here is a link 一个关于如何确定文件何时可以下载的示例。
我正在尝试从 amazon glacier 下载文件。我已经开始了我的工作并成功获得了我的 jobId。
现在我正在使用下面的代码下载我存档的上传文件,但我看到了这个回复
object(Aws\Result)#129 (2) {
["data":"Aws\Result":private]=> array(8) {
["body"]=> object(GuzzleHttp\Psr7\Stream)#114 (7) {
{"stream":"GuzzleHttp\Psr7\Stream":private]=> resource(118) of type (stream)
["size":"GuzzleHttp\Psr7\Stream":private]=> NULL
["seekable":"GuzzleHttp\Psr7\Stream":private]=> bool(true)
["readable":"GuzzleHttp\Psr7\Stream":private]=> bool(true)
["writable":"GuzzleHttp\Psr7\Stream":private]=> bool(true)
["uri":"GuzzleHttp\Psr7\Stream":private]=> string(10) "php://temp"
["customMetadata":"GuzzleHttp\Psr7\Stream":private]=> array(0) { } }
["checksum"]=> string(0) ""
["status"]=> int(200)
["contentRange"]=> string(0) ""
["acceptRanges"]=> string(5) "bytes"
["contentType"]=> string(16) "application/json"
["archiveDescription"]=> string(0) ""
["@metadata"]=> array(4) {
["statusCode"]=> int(200)
["effectiveUri"]=> string(161) "https://glacier.us-east-2.amazonaws.com/-/vaults/myvault/jobs/my-jobid-removed-for-privacy/output"
["headers"]=> array(5) {
["x-amzn-requestid"]=> string(47) "AXVtTY2JMZzODN_Yya2c"
["accept-ranges"]=> string(5) "bytes"
["content-type"]=> string(16) "application/json"
["content-length"]=> string(3) "124"
["date"]=> string(29) "Thu, 15 Aug 2019 14:51:40 GMT"
}
["transferStats"]=> array(1) {
["http"]=> array(1) {
[0]=> array(0) { }
}
}
}
}
["monitoringEvents":"Aws\Result":private]=> array(0) { }
}
我需要设置什么权限吗。我的存档文件是私有的。谁能告诉我一些事情
这里是代码
require 'vendor/autoload.php';
use Aws\Glacier\GlacierClient;
use Aws\Glacier\TreeHash;
$client = new GlacierClient([
'version' => 'latest',
'region' => 'my-region',
'credentials' => [
'key' => 'my key',
'secret' => 'my secret'
]
]);
$result = $client->getJobOutput([
'accountId' => '-',
'jobId' => 'my job id',
'vaultName' => 'my valt name here',
]);
var_dump($result);
echo $data = $result->get('body');
不要忘记 Glacier 中的文件需要一些时间才能 "unfreeze" 变得可下载和可用。这就是 Glacier 比 S3 这样的东西便宜得多的确切原因。
Here is a link 一个关于如何确定文件何时可以下载的示例。