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);
}
}
Aggregations