Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon s3 基于元数据选择键,AmazonS3可能吗?_Amazon S3_Amazon Web Services_Boto - Fatal编程技术网

Amazon s3 基于元数据选择键,AmazonS3可能吗?

Amazon s3 基于元数据选择键,AmazonS3可能吗?,amazon-s3,amazon-web-services,boto,Amazon S3,Amazon Web Services,Boto,我将文件发送到我的S3存储桶,这些文件基本上是Gzip数据库转储。它们是一个人类可读的日期(“2010-05-04.dump”),除此之外,我还将元数据字段设置为转储的UNIX时间 我想编写一个脚本,从bucket中检索最新的转储。也就是说,我想要具有最大unix时间元数据值的密钥。AmazonS3有可能做到这一点吗?或者S3不是这样工作的 我在这里同时使用命令行工具aws和python库boto,这似乎是可行的,但可能不是最理想的(使用boto) 嗯,我不认为你可以避免遍历所有键。(但是get

我将文件发送到我的S3存储桶,这些文件基本上是Gzip数据库转储。它们是一个人类可读的日期(“2010-05-04.dump”),除此之外,我还将元数据字段设置为转储的UNIX时间

我想编写一个脚本,从bucket中检索最新的转储。也就是说,我想要具有最大unix时间元数据值的密钥。AmazonS3有可能做到这一点吗?或者S3不是这样工作的


我在这里同时使用命令行工具aws和python库boto,这似乎是可行的,但可能不是最理想的(使用boto)


嗯,我不认为你可以避免遍历所有键。(但是
get_metadata
是否对S3进行另一次查询?如果是,只使用文件名就可以避免这种情况。)啊,但是您每天可能有几个文件吗?在这种情况下,您确实需要使用时间戳(或将时间添加到文件名中)。当涉及元数据时,似乎大多数人都同时使用simpledb和s3:
latest_key = None
latest_ts = 0
for key in bucket.get_all_keys():
    # go through all keys and return the one with the higest timestamp
    ts = key.get_metadata('timestamp')

    if ts > latest_ts:
        latest_key = key
        latest_ts = ts