AWS S3 自动文件上传 [英] AWS S3 automated file upload

查看:75
本文介绍了AWS S3 自动文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动化在两个 S3 存储桶之间复制文件的过程.

I wanted to automate the process of copying files between two S3 buckets.

场景:每当相同的文件上传到 S3(第一个存储桶)时,旧版本的文件应移动到另一个 S3 存储桶(第二个 S3),并且只有较新版本的文件应驻留在第一个存储桶中.请向我建议执行此操作的过程

scenario: whenever the same files are getting uploaded to S3(first bucket) the older versions of the file should be moved to another S3 bucket(second S3) and only the newer version file should reside in the first bucket. Please suggest to me the process of doing this

推荐答案

当使用与现有对象相同的密钥(文件名)将对象上传到 Amazon S3 时,新对象将覆盖em> 现有对象.

When an object is uploaded to Amazon S3 with the same Key (filename) as an existing object, the new object will overwrite the existing object.

这可以通过激活版本控制来避免 在存储桶上,它将保留一个对象的所有 版本.因此,如果使用相同的 Key 上传新对象,则旧对象将成为以前的版本",并且仍可在 S3 中访问.(您将支付所有版本的存储费用.)

This can be avoided by activating Versioning on the bucket, which will retain all versions of an object. So, if a new object is uploaded with the same Key, then the old object becomes a 'previous version' and is still accessible in S3. (You will pay for the storage of all versions.)

如果您的要求是保留以前版本的对象,那么这应该足以满足您的需要,而无需将旧版本复制到不同的存储桶中.

If your requirements are to preserve previous versions of objects, then this should be sufficient for your need, without having to copy the older version to a different bucket.

如果你真的想按照你的要求去做,那么你需要:

If you really wanted to do as you ask, then you would need:

  • 版本控制已开启(以保留旧版本)
  • 一个由上传触发的 AWS Lambda 函数,它将版本复制到不同的存储桶,并可选择删除旧版本"
  • 计划,当有另一个上传同一对象时该怎么办——是否应该将其复制到另一个存储桶"并覆盖旧版本已经在了吗?它可能也需要版本控制!
  • Versioning turned on (to preserve older versions)
  • An AWS Lambda function that is triggered by the upload that will copy the old version to a different bucket and optionally delete the 'old version'
  • A plan for what to do when there is another upload of the same object -- should it copy it to the 'other bucket' and overwrite the older version that is already there? It might need Versioning too!

这篇关于AWS S3 自动文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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