ruby/example_code/s3/s3_ruby_bucket_cors.rb
# Replace us-west-2 with the AWS Region you're using for Amazon S3.

Replace us-west-2 with the AWS Region you're using for Amazon S3.
Replace us - west - 2 with the AWS Region you ' re using for Amazon S3 .
def run_me
  bucket_name = 'doc-example-bucket'
  allowed_methods = %w[GET PUT POST DELETE]
  allowed_origins = %w[http://www.example.com]
  allowed_headers = %w[*]
  expose_headers = %w[x-amz-server-side-encryption x-amz-request-id x-amz-id-2]
  max_age_seconds = 3000
  region = 'us-west-2'
  s3_client = Aws::S3::Client.new(region: region)
  if bucket_cors_rule_set?(
    s3_client,
    bucket_name,
    allowed_methods,
    allowed_origins,
    allowed_headers,
    expose_headers,
    max_age_seconds
  )
    puts 'CORS rule set. Current rules:'
    puts bucket_cors_rules(s3_client, bucket_name)
  else
    puts 'CORS rule not set.'
  end
end
def run_me bucket_name = 'doc-example-bucket' allowed_methods = %w[ GET PUT POST DELETE ] allowed_origins = %w[ http://www.example.com ] allowed_headers = %w[ * ] expose_headers = %w[ x-amz-server-side-encryption x-amz-request-id x-amz-id-2 ] max_age_seconds = 3000 region = 'us-west-2' s3_client = Aws :: S3 :: Client . new ( region : region ) if bucket_cors_rule_set? ( s3_client , bucket_name , allowed_methods , allowed_origins , allowed_headers , expose_headers , max_age_seconds ) puts 'CORS rule set. Current rules:' puts bucket_cors_rules ( s3_client , bucket_name ) else puts 'CORS rule not set.' end end
Replace us-west-2 with the AWS Region you're using for Amazon S3.
Replace us - west - 2 with the AWS Region you ' re using for Amazon S3 .