使用API​​以编程方式在Amazon S3和Glacier之间移动文件,反之亦然 [英] Move files between amazon S3 to Glacier and vice versa programmatically using API

查看:146
本文介绍了使用API​​以编程方式在Amazon S3和Glacier之间移动文件,反之亦然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Amazon的S3和冰川服务创建基于PHP的Web应用程序。

I am creating a PHP based web application using Amazon's S3 and glacier services.

现在,我想为网站用户提供一个功能,使他们可以选择任何文件并将其存档(意味着将文件从S3移至Glacier)和取消存档(意味着将文件从Glacier移至S3)。

Now I want to give my site users a feature that they can choose any file and make it archive (means move file from S3 to Glacier) and unarchive (means move file from Glacier to S3).

我已经进行了一些研究,但没有发现任何内容。使用亚马逊API的可能方法。

I have done some research and didn't find any possible way using Amazon's API.

问题

如何使用API​​在S3和冰川之间移动文件?

How can I move files between S3 and glacier using API?

推荐答案

您可以使用Glacier API将文件上传到Glacier保管库,但我不建议这样做。我们的备份应用的先前版本可以做到这一点。当您上传文件时,它将获得一个随机分配的名称。您可以将文件名添加到文件的元数据中,但是如果要获取Glacier保管库中内容的列表,则必须查询,然后等待3-5个小时以获取列表。

You could use the Glacier API to upload a file to a Glacier vault, but I don't recommend it. The previous version of our backup app did that. When you upload a file it gets a randomly-assigned name. You can add put your filename in the metadata of the file, but if you want a list of what's in the Glacier vault you have to query and then wait 3-5 hours for the list.

生命周期策略是使用Glacier的另一种方法。当前版本的Arq使用它们是因为每个对象仍然看起来像S3对象(没有随机的对象名称,没有延迟获取对象列表),但是对象内容位于Glacier存储中。唯一的区别是获取对象的内容是一个两步过程:您必须对要求该对象可下载;准备就绪后,您可以下载。如果您要求以太快的速度下载对象,还会收取高峰小时请求费。 Amazon Glacier定价很复杂。

Lifecycle policies are the other way to use Glacier. The current version of Arq uses them because each object still looks like an S3 object (no random object names, no delays in getting object lists), but the object contents are in Glacier storage. The only difference is that getting the object contents is a 2-step process: you have to make an API call to request that the object be made downloadable; when it's ready, you can download it. Also there's a "peak hourly request fee" that comes into play if you request objects be made downloadable at too fast a rate. Amazon Glacier pricing is complex.

一旦对象是冰川存储类,就无法将其更改回标准存储类。您必须复制标准存储类的对象并删除Glacier对象。

Once an object is "Glacier storage class" there's no way to change it back to "Standard storage class". You have to make a copy of the object that's "Standard storage class" and delete the Glacier object.

因此,解决问题的一种简单方法是:

So maybe a simple solution to your problem is:


  1. 将数据存储在S3,标准和冰川的2个文件夹中。

  2. 设置生命周期策略,将 glacier文件夹中的所有对象推送到尽快进行冰川数据存储。

  3. 要将对象从标准移动到冰川时,请将其复制到冰川文件夹,然后删除标准文件夹中的对象(没有移动 API)。

  4. 何时您要将对象从冰川移动到标准,请执行 POST请求以还原它;恢复后,将其复制到标准文件夹,然后从冰川文件夹中删除。

  1. Store the data in 2 "folders" in S3, "standard" and "glacier".
  2. Set a lifecycle policy to push all objects in the "glacier" folder to Glacier data storage ASAP.
  3. When you want to move an object from standard to glacier, copy it to the glacier folder and delete the object in the standard folder (there's no "move" API).
  4. When you want to move an object from glacier to standard, do a POST request to restore it; when it's restored, copy it to the standard folder and delete it from the glacier folder.

这篇关于使用API​​以编程方式在Amazon S3和Glacier之间移动文件,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆