I am trying to create an archive and retrieval system in php. When the user click on archive button particular files will move to glacier storage from standard storage and when click on restore button file in the glacier storage will retrieved to standard storage.
Using AWS php SDK 3.0 api I have successfully move files to glacier vault and for retrieval an archive-retrieval job is initiated and I got the job Id after 3-5 hours and using that Job id after 5 hours I tried getJobOutput function. And I am getting the response same as mentioned in the api documentation but I am not getting the restored file in my s3 bucket.
Here is my code to upload to glacier and restore from glacier
public function archiveAndRestore() {
$this->s3Client = new S3Client(Configure::read('AWScredentials'));
$this->glacier = GlacierClient::factory(Configure::read('AWScredentials'));
// Upload to glacier
$this->s3Client->registerStreamWrapper();
$context = stream_context_create([
's3' => ['seekable' => true]
]);
$result = $this->glacier->uploadArchive(array(
'vaultName' => 'archiveTest',
'archiveDescription' => 'File Name is archiveTest.txt ',
'body' => fopen('s3://storage-bucket/Videos/archiveTest.txt', 'r', false, $context),
));
$archiveid = $result->get('archiveId');
$jobId = $this->glacier->initiateJob([
'accountId' => '-',
'vaultName' => 'archiveTest',
'jobParameters' => [
'Type' => 'archive-retrieval',
'ArchiveId' => 'ORgyyyqsKwoopp110EvFoyqj3G-csmOKLyy3IJnWF9Dpd8BJfwerEhg241nxHf6y6kNUUyhUHOaY4y8QvWBGESmAopa80f6GZ9C05tyyKANhY-qfBUB6YkfTABg',
],
]);
$this->s3Client->registerStreamWrapper();
$context = stream_context_create([
's3' => ['seekable' => true]
]);
$stream = fopen('s3://storage-bucket/RetrivedFiles/test1.txt', 'w');
$result = $this->glacier->getJobOutput([
'accountId' => '-',
'jobId' => '2dddfffffff9SwZIOPWxcB7TLm_3apNx--2rIiD7SgjOJjjkrerrcN1YCtivh_zsmpLyczY4br-bhyyX0Ev5B7e6-D1',
'vaultName' => 'archiveTest',
'saveAs' => $stream,
]);
fclose($stream);
}
According to the documentation (aws GetJobOutput operation documentation) saveAs attribute of getJobOutput function is to Specify where the contents of the operation should be downloaded. Can be the path to a file, a resource returned by fopen, or a Guzzle\Http\EntityBodyInterface object. As I am giving a path to the file in s3 also. What will be the issue. Any help is really appreciated. Thanks in advance.
This is the result contained in the response $result which is exactly same as mentioned in documentation
Aws\Result Object ( [data:Aws\Result:private] => Array ( [body] => GuzzleHttp\Psr7\Stream Object ( [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #25 [size:GuzzleHttp\Psr7\Stream:private] => [seekable:GuzzleHttp\Psr7\Stream:private] => 1 [readable:GuzzleHttp\Psr7\Stream:private] => 1 [writable:GuzzleHttp\Psr7\Stream:private] => 1 [uri:GuzzleHttp\Psr7\Stream:private] => php://temp [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array ( ) ) [checksum] => c176c1843fd0c0fc662lh9bb8de916540e6f9dpk9b22020bbb8388jk6f81d1c2 [status] => 200 [contentRange] => [acceptRanges] => bytes [contentType] => application/octet-stream [archiveDescription] => File Name is children-wide.jpg [@metadata] => Array ( [statusCode] => 200 [effectiveUri] => https://glacier.region-name.amazonaws.com/-/vaults/vaultname/jobs/gFdjAl4xhTAVEnmffgfg-Ao3-xmmjghfmqkCLOR1m34gHLQpMd0a3WKCiRRrItv2bklawwZnq9KeIch3LKs8suZoJwk2_/output [headers] => Array ( [x-amzn-requestid] => NzAiVAfrMQbpSjj-2228iiKWK_VteDwNyFTUR7Kyu0duno [x-amz-sha256-tree-hash] => c176c1843khfullc662f09bb8de916540e6f9dcc9b22020bbb8388de6f81d1c2 [accept-ranges] => bytes [x-amz-archive-description] => File Name is children-wide.jpg [content-type] => application/octet-stream [content-length] => 1452770 [date] => Tue, 31 Jan 2017 03:34:26 GMT [connection] => close ) [transferStats] => Array ( [http] => Array ( [0] => Array ( ) ) ) ) ) )