[英]How to upload a file to amazon Glacier using Nodejs?
I found this example on the amazon aws docs. 我在亚马逊aws文档上找到了这个例子 。
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? 但是我不知道文件在哪里,或者如何将其发送到冰川服务器?
The file is stored in the vaultName
, what ever value you provide there. 该文件存储在vaultName
,无论您在其中提供什么值。 The data.archiveId
is the representation of the file. data.archiveId
是文件的表示形式。 The body
is the file it self. body
就是它自身的文件。
Here is a more general overview of Glacier 这是冰川的一般概述
Q: How is data within Amazon Glacier organized? 问:Amazon Glacier中的数据如何组织?
Q: How do vaults work? 问:保险库如何工作?
Q: What is an archive? 问:什么是存档?
Cody Example: (As provided by hitautodestruct) 科迪示例:(由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);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.