Am trying to download files from amazon glacier. I have initiated my jobs and have succesfully gotten my jobId.
Now am using code below to download my archived uploaded files but am shown this response
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) { }
}
Do I need to set any permission. I s my archive file private. can someone tell me something
here is the code
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');
Don't forget that files from Glacier take time to "unfreeze" to become downloadable and available. This is the exact reason why Glacier is so much more cheaper than something like S3.
Here is a link to an example on how to find out when the files are ready to be downloaded.