【Java-S3】解决亚马逊S3仅为一个存储桶返回1000个条目的问题(使用java sdk)

public static long getS3SampleDateSize(String cosPartPath) {

        long dataSize = 0L;
        List<S3ObjectSummary> objects = new ArrayList<S3ObjectSummary>();
        ObjectListing result = s3.listObjects(bucketName, cosPartPath);
        objects.addAll(result.getObjectSummaries());

        while (result.isTruncated()) {
            result = s3.listNextBatchOfObjects(result);
            objects.addAll(result.getObjectSummaries());
        }
        for (S3ObjectSummary os : objects) {
            dataSize += os.getSize();
        }

        return dataSize;
    }

详情可见:http://cn.voidcc.com/question/p-zlgoipvp-bcu.html

你可能感兴趣的:(Java,java,开发语言)