use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.
the class DeleteWebsiteConfiguration method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <bucketName>\n\n" + "Where:\n" + " bucketName - the Amazon S3 bucket to delete the website configuration from.\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String bucketName = args[0];
System.out.format("Deleting website configuration for Amazon S3 bucket: %s\n", bucketName);
Region region = Region.US_WEST_2;
S3Client s3 = S3Client.builder().region(region).build();
deleteBucketWebsiteConfig(s3, bucketName);
System.out.println("Done!");
s3.close();
}
use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.
the class S3Service method getClient.
private S3Client getClient() {
Region region = Region.US_EAST_1;
S3Client s3 = S3Client.builder().region(region).build();
return s3;
}
use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.
the class S3Service method listBucketObjects.
// Returns the names of all images in the given bucket.
public List<String> listBucketObjects(String bucketName) {
S3Client s3 = getClient();
String keyName;
List<String> keys = new ArrayList<>();
try {
ListObjectsRequest listObjects = ListObjectsRequest.builder().bucket(bucketName).build();
ListObjectsResponse res = s3.listObjects(listObjects);
List<S3Object> objects = res.contents();
for (S3Object myValue : objects) {
keyName = myValue.key();
keys.add(keyName);
}
return keys;
} catch (S3Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return null;
}
use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.
the class S3Service method deleteTagFromObject.
// Delete tags from the given object.
public void deleteTagFromObject(String bucketName, String key) {
try {
DeleteObjectTaggingRequest deleteObjectTaggingRequest = DeleteObjectTaggingRequest.builder().key(key).bucket(bucketName).build();
S3Client s3 = getClient();
s3.deleteObjectTagging(deleteObjectTaggingRequest);
} catch (S3Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.
the class S3Service method getObjectBytes.
public byte[] getObjectBytes(String bucketName, String keyName) {
S3Client s3 = getClient();
try {
GetObjectRequest objectRequest = GetObjectRequest.builder().key(keyName).bucket(bucketName).build();
// Return the byte[] from this object.
ResponseBytes<GetObjectResponse> objectBytes = s3.getObjectAsBytes(objectRequest);
return objectBytes.asByteArray();
} catch (S3Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return null;
}
Aggregations