Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active February 12, 2019 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/84f0fc5674d75d5ce8fba89e66400668 to your computer and use it in GitHub Desktop.
Save abhirockzz/84f0fc5674d75d5ce8fba89e66400668 to your computer and use it in GitHub Desktop.
public List<String> handle(String bucketName) {
if (objStoreClient == null) {
System.err.println("There was a problem creating the ObjectStorageClient object. Please check logs");
return Collections.emptyList();
}
List<String> objNames = null;
try {
String nameSpace = System.getenv().get("NAMESPACE");
ListObjectsRequest lor = ListObjectsRequest.builder()
.namespaceName(nameSpace)
.bucketName(bucketName)
.build();
System.err.println("Listing objects from bucket " + bucketName);
ListObjectsResponse response = objStoreClient.listObjects(lor);
objNames = response.getListObjects().getObjects().stream()
.map((objSummary) -> objSummary.getName())
.collect(Collectors.toList());
System.err.println("Got list of objects in bucket " + bucketName);
} catch (Throwable e) {
System.err.println("Error fetching object list from bucket " + e.getMessage());
}
return objNames;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment