简体   繁体   English

如何使用ruby和aws-sdk将大型存档上传到Amazon Glacier?

[英]How to upload large archive to Amazon Glacier using ruby and aws-sdk?

The amazon documentation for glacier doesn't seem to include any Ruby examples and the documentation itself is rather sparse. 冰川的亚马逊文档似乎没有包含任何Ruby示例,文档本身相当稀疏。

I gather I need to instantiate a Glacier Client object and then use the upload_multipart_part method to access the Glacier API, but not sure how to massage the arguments to pass to upload_multipart_part. 我收集我需要实例化一个Glacier Client对象,然后使用upload_multipart_part方法访问Glacier API,但不知道如何按下参数传递给upload_multipart_part。 How do I calculate the checksums that AWS is looking for using ruby? 如何使用ruby计算AWS正在寻找的校验和? And what is upload_id? 什么是upload_id?

UPDATE UPDATE

Figured out most of this by reading Amazon's documentation. 通过阅读亚马逊的文档来了解大部分内容。 They don't appear to have any code samples for ruby, the github repo of code examples does not cover Glacier. 它们似乎没有任何代码样本用于ruby,代码示例的github repo不包含Glacier。 But by looking at the raw API documentation and some Java and PHP examples, it looks like I'd do this: 但是通过查看原始API文档以及一些Java和PHP示例,我看起来像是这样做的:

client = AWS::Glacier::Client.new(access_key_id: ACCESS_KEY_ID, secret_access_key: SECRET_ACCESS_KEY)
resp = client.initiate_multipart_upload(account_id: ACCOUNT_ID, vault_name: 'My Vault', archive_description: "Backup of some stuff", part_size: PART_SIZE_IN_BYTES)

And if all goes well, the Amazon API response should include a unique upload_id which I would then use in subsequent calls using client.upload_multipart_part(). 如果一切顺利,Amazon API响应应包含一个唯一的upload_id,然后我将在后续调用中使用client.upload_multipart_part()。

I'm guessing the checksums can be calculated like this: 我猜测校验和可以像这样计算:

Digest::SHA256.file(file_to_upload).hexdigest

UPDATE 2 更新2

Seems like this has already been solved: 似乎已经解决了这个问题:

https://github.com/fog/fog https://github.com/fog/fog

For anyone else interested, this link is helpful, pretty much covers most of what you need: 对于其他感兴趣的人,此链接很有帮助,几乎涵盖了您需要的大部分内容:

http://www.spacevatican.org/2012/9/4/using-glacier-with-fog/ http://www.spacevatican.org/2012/9/4/using-glacier-with-fog/

It doesn't really provide all details on how to instantiate a glacier object: 它并没有真正提供有关如何实例化冰川对象的所有细节:

glacier = Fog::AWS::Glacier.new({
  :aws_access_key_id => YOUR_ACCESS_KEY_ID,
  :aws_secret_access_key => YOUR_SECRET_ACCESS_KEY
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM