@@ -0,0 +1,2607 @@
+package de.jeha.s3pt.tools;%0A%0Aimport com.amazonaws.ClientConfiguration;%0Aimport com.amazonaws.Protocol;%0Aimport com.amazonaws.auth.AWSCredentials;%0Aimport com.amazonaws.auth.BasicAWSCredentials;%0Aimport com.amazonaws.auth.SignerFactory;%0Aimport com.amazonaws.services.s3.AmazonS3;%0Aimport com.amazonaws.services.s3.AmazonS3Client;%0Aimport com.amazonaws.services.s3.internal.S3Signer;%0Aimport com.amazonaws.services.s3.model.ObjectListing;%0Aimport de.jeha.s3pt.Constants;%0Aimport de.jeha.s3pt.utils.UserProperties;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.IOException;%0Aimport java.util.Locale;%0Aimport java.util.Properties;%0A%0A/**%0A * @author jenshadlich@googlemail.com%0A */%0Apublic class CountObjects %7B%0A%0A    private static final Logger LOG = LoggerFactory.getLogger(CountObjects.class);%0A%0A    public static void main(String... args) throws IOException %7B%0A        Locale.setDefault(Locale.ENGLISH);%0A%0A        Properties userProperties = UserProperties.read(%22s3pt%22);%0A%0A        final String accessKey = userProperties.getProperty(%22accessKey%22);%0A        final String secretKey = userProperties.getProperty(%22secretKey%22);%0A        final String endpoint = userProperties.getProperty(%22endpoint%22);%0A        final String bucket = %22my-bucket%22;%0A%0A        SignerFactory.registerSigner(Constants.S3_SIGNER, S3Signer.class);%0A%0A        AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);%0A%0A        ClientConfiguration clientConfig = new ClientConfiguration()%0A                .withProtocol(Protocol.HTTP)%0A                .withUserAgent(%22CountObjects%22)%0A                .withSignerOverride(Constants.S3_SIGNER);%0A%0A        AmazonS3 s3Client = new AmazonS3Client(credentials, clientConfig);%0A        s3Client.setEndpoint(endpoint);%0A%0A        int objectCount = 0;%0A        int chunks = 0;%0A%0A        LOG.info(%22Start: bucket '%7B%7D'%22, bucket);%0A%0A        boolean truncated;%0A        ObjectListing previousObjectListing = null;%0A        do %7B%0A            chunks++;%0A            System.out.print(%22.%22);%0A            System.out.flush();%0A            if (chunks %25 100 == 0) %7B%0A                System.out.println();%0A            %7D%0A%0A            ObjectListing objectListing = (previousObjectListing != null)%0A                    ? s3Client.listNextBatchOfObjects(previousObjectListing)%0A                    : s3Client.listObjects(bucket);%0A            previousObjectListing = objectListing;%0A            truncated = objectListing.isTruncated();%0A%0A            objectCount += objectListing.getObjectSummaries().size();%0A        %7D while (truncated);%0A%0A        System.out.println();%0A        LOG.info(%22#objects: %7B%7D%22, objectCount);%0A    %7D%0A%0A%7D%0A

add tool to count objects per bucket