简体   繁体   English

使用Java查找在最近1小时内添加到S3存储桶文件夹的文件

[英]Using Java find files added to S3 bucket folder in the last 1 hour

We have 1,000,000 files in an S3 folder. S3文件夹中有1,000,000个文件。 Every hour some new files are added to the above folder. 每小时都有一些新文件添加到上述文件夹中。

Using Java how do i find the files added in the last 5 mins or last 1 hour? 使用Java如何查找最近5分钟或最近1小时添加的文件?

The most straightforward way to do this is to scan the bucket and look for new timestamps. 最简单的方法是扫描存储桶并寻找新的时间戳。 This is expensive, slow, and really a bad idea. 这是昂贵的,缓慢的,实际上是一个坏主意。

ObjectListing  objList = s3.listObjects(bucketname)
for (S3ObjectSummary obj in objList.getObjectSummaries()) {
  // compare obj.getLastModified(), a Date object
}

Second, you could structure your uploads to be lexicographically consistent to the date, then scan for a partial key. 其次,您可以将您的上载安排为与日期在字典上一致,然后扫描部分密钥。 In the following case I'm scanning for entries in a given hour: 在以下情况下,我将扫描给定小时内的条目:

s3.listObjects(bucketname, "2015-02-01-15")

Finally, the best option is to use the relatively new S3 Event Notifications to add each key to a SQS queue. 最后,最好的选择是使用相对较新的S3事件通知将每个密钥添加到SQS队列。 I'm not going to detail this, even in pseudocode, but Eric Hammond has a good entry detailing how to do this . 即使是伪代码,我也不会详细介绍它,但是Eric Hammond有一个很好的条目详细介绍了如何执行此操作

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

相关问题 我们如何使用 Java SDK 从 S3 存储桶下载没有文件夹的多个文件 - How can we download multiple files without folder from S3 bucket using Java SDK 使用 Java sdk 删除 aws s3 存储桶中的文件夹 - Delete a folder in aws s3 bucket using Java sdk 使用 JAVA 在 S3 存储桶上放置/读取文件 - Put/read files on S3 bucket using JAVA Amazon S3-使用Java API递归列出S3存储桶中的所有zip文件 - Amazon S3 - List all the zip files recursively within S3 bucket using Java API 如何使用 AWS Java SDK for S3 查询 AWS S3 存储桶以匹配对象(文件)名称 - how to query AWS S3 bucket for matching objects(files) names using AWS Java SDK for S3 列出 AWS S3 存储桶的特定“文件夹”中的文件 - Listing files in a specific “folder” of a AWS S3 bucket 将文件从 box 文件夹复制到 AWS s3 存储桶 - Copy files from box folder to AWS s3 bucket 使用适用于Amazon S3存储桶的Java SDK下载大量文件 - Download a Large Number of Files Using the Java SDK for Amazon S3 Bucket 尝试使用Java SDK从S3存储桶下载文件,isStandardEndpoint上的空指针异常 - Trying to download files from S3 Bucket using Java SDK, Null pointer Exception on isStandardEndpoint 如何使用 aws java sdk 将文件从 S3 存储桶从一个区域复制到另一个区域? - How to copy files from S3 bucket from one region to another region using aws java sdk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM