Search in sources :

Example 1 with GetBucketCorsRequest

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

the class S3Cors method getBucketCorsInformation.

public static void getBucketCorsInformation(S3Client s3, String bucketName, String accountId) {
    try {
        GetBucketCorsRequest bucketCorsRequest = GetBucketCorsRequest.builder().bucket(bucketName).expectedBucketOwner(accountId).build();
        GetBucketCorsResponse corsResponse = s3.getBucketCors(bucketCorsRequest);
        List<CORSRule> corsRules = corsResponse.corsRules();
        for (CORSRule rule : corsRules) {
            System.out.println("allowOrigins: " + rule.allowedOrigins());
            System.out.println("AllowedMethod: " + rule.allowedMethods());
        }
    } catch (S3Exception e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : GetBucketCorsRequest(software.amazon.awssdk.services.s3.model.GetBucketCorsRequest) S3Exception(software.amazon.awssdk.services.s3.model.S3Exception) CORSRule(software.amazon.awssdk.services.s3.model.CORSRule) GetBucketCorsResponse(software.amazon.awssdk.services.s3.model.GetBucketCorsResponse)

Aggregations

CORSRule (software.amazon.awssdk.services.s3.model.CORSRule)1 GetBucketCorsRequest (software.amazon.awssdk.services.s3.model.GetBucketCorsRequest)1 GetBucketCorsResponse (software.amazon.awssdk.services.s3.model.GetBucketCorsResponse)1 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)1