Module: Google::Cloud::Storage
- Defined in:
- lib/google/cloud/storage.rb,
lib/google/cloud/storage/file.rb,
lib/google/cloud/storage/bucket.rb,
lib/google/cloud/storage/errors.rb,
lib/google/cloud/storage/policy.rb,
lib/google/cloud/storage/convert.rb,
lib/google/cloud/storage/project.rb,
lib/google/cloud/storage/service.rb,
lib/google/cloud/storage/version.rb,
lib/google/cloud/storage/file/acl.rb,
lib/google/cloud/storage/file/list.rb,
lib/google/cloud/storage/bucket/acl.rb,
lib/google/cloud/storage/bucket/cors.rb,
lib/google/cloud/storage/bucket/list.rb,
lib/google/cloud/storage/credentials.rb,
lib/google/cloud/storage/file/signer.rb,
lib/google/cloud/storage/post_object.rb,
lib/google/cloud/storage/notification.rb,
lib/google/cloud/storage/file/verifier.rb,
lib/google/cloud/storage/bucket/lifecycle.rb
Overview
Google Cloud Storage
Google Cloud Storage is an Internet service to store data in Google's cloud. It allows world-wide storage and retrieval of any amount of data and at any time, taking advantage of Google's own reliable and fast networking infrastructure to perform data operations in a cost effective manner.
See Storage Overview.
Defined Under Namespace
Classes: Bucket, Credentials, File, FileVerificationError, Notification, Policy, PostObject, Project, SignedUrlUnavailable
Constant Summary collapse
- GOOGLEAPIS_URL =
"https://storage.googleapis.com".freeze
- VERSION =
"1.15.0".freeze
Class Method Summary collapse
-
.anonymous(retries: nil, timeout: nil) ⇒ Google::Cloud::Storage::Project
Creates an unauthenticated, anonymous client for retrieving public data from the Storage service.
-
.configure {|Google::Cloud.configure.storage| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Storage library.
-
.new(project_id: nil, credentials: nil, scope: nil, retries: nil, timeout: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Storage::Project
Creates a new object for connecting to the Storage service.
Class Method Details
.anonymous(retries: nil, timeout: nil) ⇒ Google::Cloud::Storage::Project
Creates an unauthenticated, anonymous client for retrieving public data from the Storage service. Each call creates a new connection.
119 120 121 122 123 |
# File 'lib/google/cloud/storage.rb', line 119 def self.anonymous retries: nil, timeout: nil Storage::Project.new( Storage::Service.new(nil, nil, retries: retries, timeout: timeout) ) end |
.configure {|Google::Cloud.configure.storage| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Storage library.
The following Storage configuration parameters are supported:
project_id
- (String) Identifier for a Storage project. (The parameterproject
is considered deprecated, but may also be used.)credentials
- (String, Hash, Google::Auth::Credentials) The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Credentials) (The parameterkeyfile
is considered deprecated, but may also be used.)scope
- (String, Array) The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. retries
- (Integer) Number of times to retry requests on server error.timeout
- (Integer) Default timeout to use in requests.
145 146 147 148 149 |
# File 'lib/google/cloud/storage.rb', line 145 def self.configure yield Google::Cloud.configure.storage if block_given? Google::Cloud.configure.storage end |
.new(project_id: nil, credentials: nil, scope: nil, retries: nil, timeout: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Storage::Project
Creates a new object for connecting to the Storage service. Each call creates a new connection.
For more information on connecting to Google Cloud see the Authentication Guide.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/google/cloud/storage.rb', line 76 def self.new project_id: nil, credentials: nil, scope: nil, retries: nil, timeout: nil, project: nil, keyfile: nil project_id ||= (project || default_project_id) project_id = project_id.to_s # Always cast to a string raise ArgumentError, "project_id is missing" if project_id.empty? scope ||= configure.scope retries ||= configure.retries timeout ||= configure.timeout credentials ||= (keyfile || default_credentials(scope: scope)) unless credentials.is_a? Google::Auth::Credentials credentials = Storage::Credentials.new credentials, scope: scope end Storage::Project.new( Storage::Service.new( project_id, credentials, retries: retries, timeout: timeout ) ) end |