class Google::Cloud::Storage::Bucket::Cors::Rule
rule.max_age #=> 3600
rule.headers #=> [“X-My-Custom-Header”]
rule.methods #=> [“GET”,“POST”,“DELETE”]
rule.origin #=> [“example.org”]
rule = bucket.cors.first
bucket.cors.size #=> 2
bucket = storage.bucket “my-bucket”
storage = Google::Cloud::Storage.new
require “google/cloud/storage”
@example Retrieving the bucket’s CORS rules.
minutes.)
in a preflight result cache. The default value is ‘1800` (30
how many seconds the results of a preflight request can be cached
Access-Control-Max-Age header in the preflight response. Indicates
@attr [String] max_age The value to send in the
actual request.
Indicates the custom request headers that may be used in the
Access-Control-Allow-Headers header in the preflight response.
@attr [String] headers The list of header field names to send in the
“any method”.
Note: “*” is permitted in the list of methods, and means
origin resource sharing with the bucket. (GET, OPTIONS, POST, etc)
@attr [String] methods The list of HTTP methods permitted in cross
“any Origin”.
bucket. Note: “*” is permitted in the list of origins, and means
or origins permitted for cross origin resource sharing with the
@attr [String] origin The [origin](tools.ietf.org/html/rfc6454)
Resource Sharing (CORS)
@see cloud.google.com/storage/docs/cross-origin Cross-Origin
{Bucket#cors}.
Represents a website CORS rule for a bucket. Accessed via
# Bucket Cors Rule
#
def self.from_gapi gapi
- Private: -
def self.from_gapi gapi new gapi.origin.dup, gapi.http_method.dup, headers: gapi.response_header.dup, max_age: gapi.max_age_seconds end
def freeze
- Private: -
def freeze @origin.freeze @methods.freeze @headers.freeze super end
def initialize origin, methods, headers: nil, max_age: nil
- Private: -
def initialize origin, methods, headers: nil, max_age: nil @origin = Array(origin) @methods = Array(methods) @headers = Array(headers) @max_age = max_age || 1800 end
def to_gapi
- Private: -
def to_gapi Google::Apis::StorageV1::Bucket::CorsConfiguration.new( origin: Array(origin).dup, http_method: Array(methods).dup, response_header: Array(headers).dup, max_age_seconds: max_age ) end