Search in sources :

Example 1 with PutBucketWebsiteRequest

use of software.amazon.awssdk.services.s3.model.PutBucketWebsiteRequest in project aws-doc-sdk-examples by awsdocs.

the class SetWebsiteConfiguration method setWebsiteConfig.

// snippet-start:[s3.java2.set_website_configuration.main]
public static void setWebsiteConfig(S3Client s3, String bucketName, String indexDoc) {
    try {
        WebsiteConfiguration websiteConfig = WebsiteConfiguration.builder().indexDocument(IndexDocument.builder().suffix(indexDoc).build()).build();
        PutBucketWebsiteRequest pubWebsiteReq = PutBucketWebsiteRequest.builder().bucket(bucketName).websiteConfiguration(websiteConfig).build();
        s3.putBucketWebsite(pubWebsiteReq);
        System.out.println("The call was successful");
    } catch (S3Exception e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : S3Exception(software.amazon.awssdk.services.s3.model.S3Exception) WebsiteConfiguration(software.amazon.awssdk.services.s3.model.WebsiteConfiguration) PutBucketWebsiteRequest(software.amazon.awssdk.services.s3.model.PutBucketWebsiteRequest)

Aggregations

PutBucketWebsiteRequest (software.amazon.awssdk.services.s3.model.PutBucketWebsiteRequest)1 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)1 WebsiteConfiguration (software.amazon.awssdk.services.s3.model.WebsiteConfiguration)1