How do you search an amazon s3 bucket?

后端 未结 21 2388
渐次进展
渐次进展 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:31

    I did something as below to find patterns in my bucket

    def getListOfPrefixesFromS3(dataPath: String, prefix: String, delimiter: String, batchSize: Integer): List[String] = {
        var s3Client = new AmazonS3Client()
        var listObjectsRequest = new ListObjectsRequest().withBucketName(dataPath).withMaxKeys(batchSize).withPrefix(prefix).withDelimiter(delimiter)
        var objectListing: ObjectListing = null
        var res: List[String] = List()
    
        do {
          objectListing = s3Client.listObjects(listObjectsRequest)
          res = res ++ objectListing.getCommonPrefixes
          listObjectsRequest.setMarker(objectListing.getNextMarker)
        } while (objectListing.isTruncated)
        res
      }
    

    For larger buckets this consumes too much of time since all the object summaries are returned by the Aws and not only the ones that match the prefix and the delimiter. I am looking for ways to improve the performance and so far i've only found that i should name the keys and organise them in buckets properly.

提交回复
热议问题