You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.
Class: Aws::S3::BucketCors
- Inherits:
-
Resources::Resource
- Object
- Resources::Resource
- Aws::S3::BucketCors
- Defined in:
- (unknown)
Instance Attribute Summary collapse
-
#bucket_name ⇒ String
readonly
-
#cors_rules ⇒ Array<Types::CORSRule>
readonly
A set of origins and methods (cross-origin access that you want to allow).
Attributes inherited from Resources::Resource
Instance Method Summary collapse
-
#bucket ⇒ Bucket
-
#delete(options = {}) ⇒ Struct
Deletes the
corsconfiguration information set for the bucket.To use this operation, you must have permission to perform the
s3:PutBucketCORSaction. -
#initialize ⇒ Object
constructor
-
#put(options = {}) ⇒ Struct
Sets the
corsconfiguration for your bucket.
Methods inherited from Resources::Resource
add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until
Methods included from Resources::OperationMethods
#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations
Constructor Details
Instance Attribute Details
#bucket_name ⇒ String (readonly)
#cors_rules ⇒ Array<Types::CORSRule> (readonly)
A set of origins and methods (cross-origin access that you want to allow). You can add up to 100 rules to the configuration.
Instance Method Details
#bucket ⇒ Bucket
#delete(options = {}) ⇒ Struct
Deletes the cors configuration information set for the bucket.
To use this operation, you must have permission to perform the s3:PutBucketCORS action. The bucket owner has this permission by default and can grant this permission to others.
For information about cors, see Enabling Cross-Origin Resource Sharing in the Amazon Simple Storage Service Developer Guide.
Related Resources:
#put(options = {}) ⇒ Struct
Sets the cors configuration for your bucket. If the configuration exists, Amazon S3 replaces it.
To use this operation, you must be allowed to perform the s3:PutBucketCORS action. By default, the bucket owner has this permission and can grant it to others.
You set this configuration on a bucket so that the bucket can service cross-origin requests. For example, you might want to enable a request whose origin is http://www.example.com to access your Amazon S3 bucket at my.example.bucket.com by using the browser's XMLHttpRequest capability.
To enable cross-origin resource sharing (CORS) on a bucket, you add the cors subresource to the bucket. The cors subresource is an XML document in which you configure rules that identify origins and the HTTP methods that can be executed on your bucket. The document is limited to 64 KB in size.
When Amazon S3 receives a cross-origin request (or a pre-flight OPTIONS request) against a bucket, it evaluates the cors configuration on the bucket and uses the first CORSRule rule that matches the incoming browser request to enable a cross-origin request. For a rule to match, the following conditions must be met:
-
The request's
Originheader must matchAllowedOriginelements. -
The request method (for example, GET, PUT, HEAD, and so on) or the
Access-Control-Request-Methodheader in case of a pre-flightOPTIONSrequest must be one of theAllowedMethodelements. -
Every header specified in the
Access-Control-Request-Headersrequest header of a pre-flight request must match anAllowedHeaderelement.
For more information about CORS, go to Enabling Cross-Origin Resource Sharing in the Amazon Simple Storage Service Developer Guide.
Related Resources