in src/main/java/com/aws/logaggregator/utils/S3Utils.java [79:115]
public List<String> getListofFiles(String bucketName) {
if (bucketName == null) {
return null;
}
ArrayList<String> files = new ArrayList<String>();
StringBuffer fileNameBuffer = new StringBuffer();
try {
AmazonS3 s3client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain());
String rootbucketName = bucketName.substring(0, bucketName.indexOf("/"));
String prefix = bucketName.substring(bucketName.indexOf("/") + 1);
Iterable<S3ObjectSummary> objectSummaries = S3Objects.withPrefix(s3client, rootbucketName, prefix);
for (S3ObjectSummary objectSummary : objectSummaries) {
if (objectSummary.getKey() != null) {
String key = objectSummary.getKey();
int lastIndex = key.lastIndexOf("/");
if (lastIndex > 0 && lastIndex + 1 != key.length()) {
String fileName = key.substring(key.lastIndexOf("/") + 1);
files.add(fileName);
///fileNameBuffer.append( fileName );
//fileNameBuffer.append( "," );
}
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return files;
}