ruby/example_code/s3/s3_ruby_bucket_cors.rb
def bucket_cors_rules(s3_client, bucket_name)
  response = s3_client.get_bucket_cors(bucket: bucket_name)
  response.cors_rules
rescue StandardError => e
  puts "Error getting CORS rules: #{e.message}"
end
# Gets the cross-origin resource sharing (CORS) rules for an Amazon S3 bucket.
#
# Prerequisites:
#
# - An Amazon S3 bucket.
#
# @param s3_client [Aws::S3::Client] An initialized Amazon S3 client.
# @param bucket_name [String] The name of the bucket.
# @returns [Array<Aws::S3::Types::CORSRule>] The list of CORS rules.
# @example
#   puts bucket_cors_rules(
#     Aws::S3::Client.new(region: 'us-west-2'),
#     'doc-example-bucket')

Gets the cross-origin resource sharing (CORS) rules for an Amazon S3 bucket.
Prerequisites.

An Amazon S3 bucket.
Gets the cross - origin resource sharing ( CORS ) rules for an Amazon S3 bucket . Prerequisites . An Amazon S3 bucket .
def bucket_cors_rules(s3_client, bucket_name)
  response = s3_client.get_bucket_cors(bucket: bucket_name)
  response.cors_rules
rescue StandardError => e
  puts "Error getting CORS rules: #{e.message}"
end
def bucket_cors_rules ( s3_client , bucket_name ) response = s3_client . get_bucket_cors ( bucket : bucket_name ) response . cors_rules rescue StandardError => e puts "Error getting CORS rules: #{e.message}" end
Gets the cross-origin resource sharing (CORS) rules for an Amazon S3 bucket.
Gets the cross - origin resource sharing ( CORS ) rules for an Amazon S3 bucket .
[Array] The list of CORS rules.
[ Array ] The list of CORS rules .
s3_client
An initialized Amazon S3 client.
An initialized Amazon S3 client .
bucket_name
The name of the bucket.
The name of the bucket .
example
puts bucket_cors_rules( Aws::S3::Client.new(region: 'us-west-2'), 'doc-example-bucket')
puts bucket_cors_rules ( Aws :: S3 :: Client . new ( region : ' us - west - 2 ' ) ' doc - example - bucket ' )