Last active
February 12, 2019 15:18
-
-
Save abhirockzz/84f0fc5674d75d5ce8fba89e66400668 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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