How to upload a file to amazon Glacier using Nodejs?

隐身守侯 提交于 2020-05-27 06:45:34

问题


I found this example on the amazon aws docs.

var glacier = new AWS.Glacier(),
    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);
});

But I don't understand where my file goes, or how to send it to the glacier servers?


回答1:


The file is stored in the vaultName, what ever value you provide there. The data.archiveId is the representation of the file. The body is the file it self.

Here is a more general overview of Glacier

Q: How is data within Amazon Glacier organized?

Q: How do vaults work?

Q: What is an archive?

Cody Example: (As provided by hitautodestruct)

var AWS = require('aws-sdk'),
    fs = require('fs'),
    glacier = new AWS.Glacier(),
    vaultName = 'YOUR_VAULT_NAME',
    // No more than 4GB otherwise use multipart upload
    file = fs.readFileSync('FILE-TO-UPLOAD.EXT');

var params = {vaultName: vaultName, body: file};
glacier.uploadArchive(params, function(err, data) {
    if (err) console.log("Error uploading archive!", err);
    else console.log("Archive ID", data.archiveId);
});


来源:https://stackoverflow.com/questions/17342255/how-to-upload-a-file-to-amazon-glacier-using-nodejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!