lib/google/cloud/storage/bucket.rb in google-cloud-storage-0.21.0 vs lib/google/cloud/storage/bucket.rb in google-cloud-storage-0.23.0
- old
+ new
@@ -103,14 +103,16 @@
# require "google/cloud/storage"
#
# storage = Google::Cloud::Storage.new
#
# bucket = storage.bucket "my-todo-app"
- # bucket.cors #=> [{"origin"=>["http://example.org"],
- # # "method"=>["GET","POST","DELETE"],
- # # "responseHeader"=>["X-My-Custom-Header"],
- # # "maxAgeSeconds"=>3600}]
+ # 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
#
# @example Updating the bucket's CORS rules inside a block.
# require "google/cloud/storage"
#
# storage = Google::Cloud::Storage.new
@@ -118,11 +120,11 @@
#
# bucket.update do |b|
# b.cors do |c|
# c.add_rule ["http://example.org", "https://example.org"],
# "*",
- # response_headers: ["X-My-Custom-Header"],
+ # headers: ["X-My-Custom-Header"],
# max_age: 3600
# end
# end
#
def cors
@@ -287,16 +289,16 @@
# @example
# require "google/cloud/storage"
#
# storage = Google::Cloud::Storage.new
#
- # bucket = storage.bucket "my-bucket"
+ # bucket = storage.bucket "my-todo-app"
# bucket.update do |b|
# b.website_main = "index.html"
# b.website_404 = "not_found.html"
- # b.cors[0]["method"] = ["GET","POST","DELETE"]
- # b.cors[1]["responseHeader"] << "X-Another-Custom-Header"
+ # b.cors[0].methods = ["GET","POST","DELETE"]
+ # b.cors[1].headers << "X-Another-Custom-Header"
# end
#
# @example New CORS rules can also be added in a nested block:
# require "google/cloud/storage"
#
@@ -305,11 +307,11 @@
#
# bucket.update do |b|
# b.cors do |c|
# c.add_rule ["http://example.org", "https://example.org"],
# "*",
- # response_headers: ["X-My-Custom-Header"],
+ # headers: ["X-My-Custom-Header"],
# max_age: 300
# end
# end
#
def update
@@ -409,25 +411,20 @@
##
# Retrieves a file matching the path.
#
# If a [customer-supplied encryption
# key](https://cloud.google.com/storage/docs/encryption#customer-supplied)
- # was used with {#create_file}, the `encryption_key` and
- # `encryption_key_sha256` options must be provided or else the file's
- # CRC32C checksum and MD5 hash will not be returned.
+ # was used with {#create_file}, the `encryption_key` option must be
+ # provided or else the file's CRC32C checksum and MD5 hash will not be
+ # returned.
#
# @param [String] path Name (path) of the file.
# @param [Integer] generation When present, selects a specific revision
# of this object. Default is the latest version.
# @param [String] encryption_key Optional. The customer-supplied,
# AES-256 encryption key used to encrypt the file, if one was provided
- # to {#create_file}. Must be provided if `encryption_key_sha256` is
- # provided.
- # @param [String] encryption_key_sha256 Optional. The SHA256 hash of the
- # customer-supplied, AES-256 encryption key used to encrypt the file,
- # if one was provided to {#create_file}. Must be provided if
- # `encryption_key` is provided.
+ # to {#create_file}.
#
# @return [Google::Cloud::Storage::File, nil] Returns nil if file does
# not exist
#
# @example
@@ -438,15 +435,13 @@
# bucket = storage.bucket "my-bucket"
#
# file = bucket.file "path/to/my-file.ext"
# puts file.name
#
- def file path, generation: nil, encryption_key: nil,
- encryption_key_sha256: nil
+ def file path, generation: nil, encryption_key: nil
ensure_service!
- options = { generation: generation, key: encryption_key,
- key_sha256: encryption_key_sha256 }
+ options = { generation: generation, key: encryption_key }
gapi = service.get_file name, path, options
File.from_gapi gapi, service
rescue Google::Cloud::NotFoundError
nil
end
@@ -457,17 +452,15 @@
# upload and the path to store it with in the bucket.
#
# #### Customer-supplied encryption keys
#
# By default, Google Cloud Storage manages server-side encryption keys
- # on your behalf. However, a [customer-supplied encryption
- # key](https://cloud.google.com/storage/docs/encryption#customer-supplied)
- # can be provided with the `encryption_key` and `encryption_key_sha256`
- # options. If given, the same key and SHA256 hash also must be provided
- # to subsequently download or copy the file. If you use
- # customer-supplied encryption keys, you must securely manage your keys
- # and ensure that they are not lost. Also, please note that file
+ # on your behalf. However, a [customer-supplied encryption key](https://cloud.google.com/storage/docs/encryption#customer-supplied)
+ # can be provided with the `encryption_key` option. If given, the same
+ # key must be provided to subsequently download or copy the file. If you
+ # use customer-supplied encryption keys, you must securely manage your
+ # keys and ensure that they are not lost. Also, please note that file
# metadata is not encrypted, with the exception of the CRC32C checksum
# and MD5 hash. The names of files and buckets are also not encrypted,
# and you can read or update the metadata of an encrypted file without
# providing the encryption key.
#
@@ -520,15 +513,11 @@
# more information.
# @param [Hash] metadata A hash of custom, user-provided web-safe keys
# and arbitrary string values that will returned with requests for the
# file as "x-goog-meta-" response headers.
# @param [String] encryption_key Optional. A customer-supplied, AES-256
- # encryption key that will be used to encrypt the file. Must be
- # provided if `encryption_key_sha256` is provided.
- # @param [String] encryption_key_sha256 Optional. The SHA256 hash of the
- # customer-supplied, AES-256 encryption key that will be used to
- # encrypt the file. Must be provided if `encryption_key` is provided.
+ # encryption key that will be used to encrypt the file.
#
# @return [Google::Cloud::Storage::File]
#
# @example
# require "google/cloud/storage"
@@ -558,34 +547,31 @@
#
# # Key generation shown for example purposes only. Write your own.
# cipher = OpenSSL::Cipher.new "aes-256-cfb"
# cipher.encrypt
# key = cipher.random_key
- # key_hash = Digest::SHA256.digest key
#
# bucket.create_file "path/to/local.file.ext",
# "destination/path/file.ext",
- # encryption_key: key,
- # encryption_key_sha256: key_hash
+ # encryption_key: key
#
# # Store your key and hash securely for later use.
# file = bucket.file "destination/path/file.ext",
- # encryption_key: key,
- # encryption_key_sha256: key_hash
+ # encryption_key: key
#
def create_file file, path = nil, acl: nil, cache_control: nil,
content_disposition: nil, content_encoding: nil,
content_language: nil, content_type: nil,
crc32c: nil, md5: nil, metadata: nil,
- encryption_key: nil, encryption_key_sha256: nil
+ encryption_key: nil
ensure_service!
options = { acl: File::Acl.predefined_rule_for(acl), md5: md5,
cache_control: cache_control, content_type: content_type,
content_disposition: content_disposition, crc32c: crc32c,
content_encoding: content_encoding,
content_language: content_language, metadata: metadata,
- key: encryption_key, key_sha256: encryption_key_sha256 }
+ key: encryption_key }
ensure_file_exists! file
# TODO: Handle file as an IO and path is missing more gracefully
path ||= Pathname(file).to_path
gapi = service.insert_file name, file, path, options
File.from_gapi gapi, service
@@ -638,11 +624,11 @@
# require "google/cloud/storage"
#
# storage = Google::Cloud::Storage.new
#
# bucket = storage.bucket "my-todo-app"
- # shared_url = bucket.signed_url "avatars/heidi/400x400.png",
+ # shared_url = bucket.signed_url "avatars/heidi/400x400.png"
#
# @example Any of the option parameters may be specified:
# require "google/cloud/storage"
#
# storage = Google::Cloud::Storage.new
@@ -650,10 +636,10 @@
# bucket = storage.bucket "my-todo-app"
# shared_url = bucket.signed_url "avatars/heidi/400x400.png",
# method: "PUT",
# expires: 300 # 5 minutes from now
#
- # @example Using the `issuer` and `signing_key` options:
+ # @example Using the issuer and signing_key options:
# require "google/cloud/storage"
#
# storage = Google::Cloud.storage
#
# bucket = storage.bucket "my-todo-app"