gpt4 book ai didi

amazon-s3 - 如何指定与目录不匹配的对象过期前缀?

转载 作者:行者123 更新时间:2023-12-02 23:25:23 25 4
gpt4 key购买 nike

我有一个包含 imgmovtmp 目录的 S3 存储桶。我希望添加到 tmp 的所有内容在超过三天后自动删除。所以我设置了object expiration我的存储桶规则如下:

  • 前缀:“tmp/”
  • 过期时间:3

问题是,虽然 tmp 内的文件按计划删除,但 tmp 本身也匹配此前缀(尽管尾部有斜杠),并且每三天就会删除一次。

是否有任何前缀可以匹配 tmp 的内容,但不匹配 tmp 本身?像“tmp/*”之类的东西(尽管这不起作用)?

最佳答案

你为什么要保留tmp

Amazon S3实际上并没有文件夹/目录的原生概念,而是仅由存储桶和对象/键组成的平面存储架构 - 大多数 S3 工具中看到的目录样式呈现(包括 AWS Management Console 本身)仅基于约定,即模拟具有相同前缀的对象的层次结构(例如,在您的情况下为 tmp/ );请参阅相应的常见问题解答 How is Amazon S3 data organized? :

Amazon S3 is a simple key-based object store. When you store data, you assign a unique object key that can later be used to retrieve the data. Keys can be any string, and can be constructed to mimic hierarchical attributes.

[emphasis mine]

此架构在Amazon S3 Concepts中有进一步详细介绍。 :

Buckets

A bucket is a container for objects stored in Amazon S3. Every object is contained in a bucket. For example, if the object named photos/puppy.jpg is stored in the johnsmith bucket, then it is addressable using the URL http://johnsmith.s3.amazonaws.com/photos/puppy.jpg

[...]

Keys

A key is the unique identifier for an object within a bucket. Every object in a bucket has exactly one key. Because the combination of a bucket, key, and version ID uniquely identify each object, Amazon S3 can be thought of as a basic data map between "bucket + key + version" and the object itself.

[emphasis mine]

因此根本不需要关心这些“目录”,只要您碰巧存储名称中带有相应前缀的对象,它们就会重新出现。

关于amazon-s3 - 如何指定与目录不匹配的对象过期前缀?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9422255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com