Cloud Storage API - Class Google::Cloud::Storage::Bucket::Cors::Rule (v1.45.0)

Reference documentation and code samples for the Cloud Storage API class Google::Cloud::Storage::Bucket::Cors::Rule.

Bucket Cors Rule

Represents a website CORS rule for a bucket. Accessed via Google::Cloud::Storage::Bucket#cors.

Inherits

  • Object

Example

Retrieving the bucket's CORS rules.

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"
bucket.cors.size #=> 2
rule = bucket.cors.first
rule.origin #=> ["http://example.org"]
rule.methods #=> ["GET","POST","DELETE"]
rule.headers #=> ["X-My-Custom-Header"]
rule.max_age #=> 3600

Methods

#headers

def headers() -> String

The list of header field names to send in the Access-Control-Allow-Headers header in the preflight response. Indicates the custom request headers that may be used in the actual request.

Returns
  • (String) — the current value of headers

#headers=

def headers=(value) -> String

The list of header field names to send in the Access-Control-Allow-Headers header in the preflight response. Indicates the custom request headers that may be used in the actual request.

Parameter
  • value (String) — the newly set value
Returns
  • (String) — the newly set value

#max_age

def max_age() -> String

The value to send in the Access-Control-Max-Age header in the preflight response. Indicates how many seconds the results of a preflight request can be cached in a preflight result cache. The default value is 1800 (30 minutes.)

Returns
  • (String) — the current value of max_age

#max_age=

def max_age=(value) -> String

The value to send in the Access-Control-Max-Age header in the preflight response. Indicates how many seconds the results of a preflight request can be cached in a preflight result cache. The default value is 1800 (30 minutes.)

Parameter
  • value (String) — the newly set value
Returns
  • (String) — the newly set value

#methods

def methods() -> String

The list of HTTP methods permitted in cross origin resource sharing with the bucket. (GET, OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and means "any method".

Returns
  • (String) — the current value of methods

#methods=

def methods=(value) -> String

The list of HTTP methods permitted in cross origin resource sharing with the bucket. (GET, OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and means "any method".

Parameter
  • value (String) — the newly set value
Returns
  • (String) — the newly set value

#origin

def origin() -> String

The origin or origins permitted for cross origin resource sharing with the bucket. Note: "*" is permitted in the list of origins, and means "any Origin".

Returns
  • (String) — the current value of origin

#origin=

def origin=(value) -> String

The origin or origins permitted for cross origin resource sharing with the bucket. Note: "*" is permitted in the list of origins, and means "any Origin".

Parameter
  • value (String) — the newly set value
Returns
  • (String) — the newly set value