简体   繁体   English

列出来自 Amazon S3 存储桶的对象

[英]Listing objects from Amazon S3 bucket

I'm planning to store a set of user related files in S3 and thinking of organizing files with prefixes similar to below in a single user-data bucket.我计划在 S3 中存储一组与用户相关的文件,并考虑在单个user-data存储桶中组织具有类似于下面的前缀的文件。

unique-user-guid/images/image1.jpg
unique-user-guid/images/image1.jpg
...
unique-user-guid/docs/file1.pdf
unique-user-guid/docs/file2.txt
...

My hope is to use a code similar to below to fetch all objects related to a specific user guid.我希望使用类似于下面的代码来获取与特定用户 guid 相关的所有对象。

    ListObjectsV2Request request = new ListObjectsV2Request();
    request.setBucketName("user-bucket");
    request.setPrefix("unique-user-guid/");
    ListObjectsV2Result result = s3Client.listObjectsV2(request);

Is it an efficient way of organizing user specific data and list objects on demand?它是组织用户特定数据和按需列出对象的有效方式吗? I'm expecting about 500k unique users in the system.我预计系统中有大约 500k 的唯一用户。

Your approach looks perfectly feasible .您的方法看起来完全可行

There is a limit of 1000 objects returned per ListObjects() call, so you might need to paginate to retrieve more results.每个ListObjects()调用返回 1000 个对象的限制,因此您可能需要分页以检索更多结果。 But, your quantities suggest that this will be rare.但是,您的数量表明这种情况很少见。

The use of setPrefix will limit the result set quite nicely and should be quite efficient due to the way that Amazon S3 stores its index.使用setPrefix很好地限制结果集,并且由于 Amazon S3 存储其索引的方式,应该非常有效。

An alternative approach would be to store objects under a unique ID (GUID), and then use a database to keep track of the objects, names, metadata, owner, etc.另一种方法是将对象存储在唯一 ID (GUID) 下,然后使用数据库跟踪对象、名称、元数据、所有者等。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM