use of com.amazonaws.services.s3.model.BucketWebsiteConfiguration in project aws-doc-sdk-examples by awsdocs.
the class GetWebsiteConfiguration method getWebsiteConfig.
public static void getWebsiteConfig(String bucket_name) {
final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
try {
BucketWebsiteConfiguration config = s3.getBucketWebsiteConfiguration(bucket_name);
if (config == null) {
System.out.println("No website configuration found!");
} else {
System.out.format("Index document: %s\n", config.getIndexDocumentSuffix());
System.out.format("Error document: %s\n", config.getErrorDocument());
}
} catch (AmazonServiceException e) {
System.err.println(e.getErrorMessage());
System.out.println("Failed to get website configuration!");
System.exit(1);
}
}
use of com.amazonaws.services.s3.model.BucketWebsiteConfiguration in project aws-doc-sdk-examples by awsdocs.
the class SetWebsiteConfiguration method setWebsiteConfig.
public static void setWebsiteConfig(String bucket_name, String index_doc, String error_doc) {
BucketWebsiteConfiguration website_config = null;
if (index_doc == null) {
website_config = new BucketWebsiteConfiguration();
} else if (error_doc == null) {
website_config = new BucketWebsiteConfiguration(index_doc);
} else {
website_config = new BucketWebsiteConfiguration(index_doc, error_doc);
}
final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
try {
s3.setBucketWebsiteConfiguration(bucket_name, website_config);
} catch (AmazonServiceException e) {
System.out.format("Failed to set website configuration for bucket '%s'!\n", bucket_name);
System.err.println(e.getErrorMessage());
System.exit(1);
}
}
Aggregations