Menu
AWS SDK for JavaScript
Developer Guide for SDK version 2.122.0

Uploading an Archive to Amazon Glacier

The following example uploads a single Buffer object as an entire archive using the uploadArchive method of the Amazon Glacier service object.

The example assumes you've already created a vault named YOUR_VAULT_NAME. The SDK automatically computes the tree hash checksum for the data uploaded, though you can override it by passing your own checksum parameter:

Copy
var glacier = new AWS.Glacier({apiVersion: '2012-06-01'}), vaultName = 'YOUR_VAULT_NAME', buffer = new Buffer(2.5 * 1024 * 1024); // 2.5MB buffer var params = {vaultName: vaultName, body: buffer}; glacier.uploadArchive(params, function(err, data) { if (err) console.log("Error uploading archive!", err); else console.log("Archive ID", data.archiveId); });