Search code examples
springspring-integrationspring-integration-sftpspring-integration-aws

How to get object count in S3 bucket for current date using spring-integration-aws?


Have a spring integration application where files are routed from a folder to S3 buckets using s3-outbound-channel-adapter. I need to know the number of files/object that are stored under S3 bucket for today's date(current date) and files having format (csv/txt) alone.

Would like to know how to get it using spring-integration-aws without using aws-sdk directly?

Observed that spring-integration-aws has a method in S3session.

@Override
    public S3ObjectSummary[] list(String path) throws IOException {
}

Do we need to use comparator on S3ObjectSummary or is there any other method available to achieve this. Any suggestion is helpful.


Solution

  • So, you use S3Session.listNames() and then filter result for desired file extensions.

    If you really need some more comprehensive logic, you can consider to use a S3RemoteFileTemplate and its executeWithClient() to access a low-level AWS API.