I have configured life cycle policy in S3, some of objects in S3 are stored in Glacier class, some of object are still in S3, now I am trying to restore objects from Glacier, I can restore objects in glacier using intiate restore in console and s3cmd line.How can i write code to restore objects in Glacier by using by Nodejs AWS SDK.
2 Answers
1
votes
You would use the S3.restoreObject()
function in the AWS SDK for NodeJS to restore an object from Glacier, as documented here.
0
votes
Thanks mark for update.I have tried using s3.restoreObject() and code is working.But i am facing following issue :{ [MalformedXML: The XML you provided was not well-formed or did not validate against out published schema}
This is code i tried:
var AWS = require('aws-sdk');
var s3 = new AWS.S3({accessKeyId: 'XXXXXXXX', secretAccessKey:'XXXXXXXXXX'});
var params = {
Bucket: 'BUCKET',
Key: 'file.json',
RestoreRequest:
{ Days: 1,
GlacierJobParameters: { Tier: 'Standard' }
}
};
s3.restoreObject (params, function(err, data)
{
if (err) console.log(err, err.stack);
else console.log(data);
});