How do you search an amazon s3 bucket?

后端 未结 21 2378
渐次进展
渐次进展 2020-11-30 18:00

I have a bucket with thousands of files in it. How can I search the bucket? Is there a tool you can recommend?

21条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 18:06

    There are (at least) two different use cases which could be described as "search the bucket":

    1. Search for something inside every object stored at the bucket; this assumes a common format for all the objects in that bucket (say, text files), etc etc. For something like this, you're forced to do what Cody Caughlan just answered. The AWS S3 docs has example code showing how to do this with the AWS SDK for Java: Listing Keys Using the AWS SDK for Java (there you'll also find PHP and C# examples).

    2. List item Search for something in the object keys contained in that bucket; S3 does have partial support for this, in the form of allowing prefix exact matches + collapsing matches after a delimiter. This is explained in more detail at the AWS S3 Developer Guide. This allows, for example, to implement "folders" through using as object keys something like

      folder/subfolder/file.txt
      If you follow this convention, most of the S3 GUIs (such as the AWS Console) will show you a folder view of your bucket.

提交回复
热议问题