class Google::Cloud::Storage::Bucket::Cors
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.
end
max_age: 3600
headers: [“X-My-Custom-Header”],
[“GET”, “POST”, “DELETE”],
c.add_rule [“example.org”, “example.org”],
c.delete_if { |r| r.origin.include? “example.com” }
# Remove all existing rules with the https protocol
c.pop
# Remove the last CORS rule from the array
bucket.cors do |c|
bucket = storage.bucket “my-bucket”
storage = Google::Cloud::Storage.new
require “google/cloud/storage”
@example
Resource Sharing (CORS)
@see cloud.google.com/storage/docs/cross-origin Cross-Origin
Accessed via {Bucket#cors}.
A special-case Array for managing the website CORS rules for a bucket.
# Bucket Cors
#
def self.from_gapi gapi_list
- Private: -
def self.from_gapi gapi_list rules = Array(gapi_list).map { |gapi| Rule.from_gapi gapi } new rules end
def add_rule origin, methods, headers: nil, max_age: nil
-
max_age
(Integer
) -- The value to send in the -
headers
(String, Array
) -- The list of header field -
methods
(String, Array
) -- The list of HTTP methods -
origin
(String, Array
) -- The
def add_rule origin, methods, headers: nil, max_age: nil push Rule.new(origin, methods, headers: headers, max_age: max_age) end
def changed?
- Private: -
def changed? @original != to_gapi.map(&:to_json) end
def freeze
- Private: -
def freeze each(&:freeze) super end
def initialize rules = []
- Private: - Initialize a new CORS rules builder with existing CORS
def initialize rules = [] super rules @original = to_gapi.map(&:to_json) end
def to_gapi
- Private: -
def to_gapi map(&:to_gapi) end