Skip to content

Instantly share code, notes, and snippets.

@ashee
Created February 6, 2020 16:26
Show Gist options
  • Save ashee/7d66ca53742ed7f4ea9de006173f41c8 to your computer and use it in GitHub Desktop.
Save ashee/7d66ca53742ed7f4ea9de006173f41c8 to your computer and use it in GitHub Desktop.
#!/bin/bash
// 2>/dev/null; OPTS="-cp $(cat cp.txt)"
// 2>/dev/null; exec groovy $OPTS "$0" "$@"; exit $?
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.*;
import software.amazon.awssdk.services.s3.model.*;
((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME)).setLevel(ch.qos.logback.classic.Level.WARN)
String bucketName = "your-bucket-name";
def client = S3Client.builder().region(Region.US_EAST_1).build();
def request =
ListObjectsV2Request
.builder()
.bucket(bucketName)
// .prefix("/")
.delimiter("/")
// .prefix("peacekeepers/year=2018/month=12/day=19")
.build();
def response = client.listObjectsV2Paginator(request);
response.each { it.contents().each {
println(it.key())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment