Methods
.storage
def self.storage(project_id = nil, credentials = nil, scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: 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.
- project_id (String) — Project identifier for the Storage service you are connecting to. If not present, the default project for the credentials is 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 Storage::Credentials)
-
scope (String, Array<String>) (defaults to: nil) —
The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.
The default scope is:
https://www.googleapis.com/auth/devstorage.full_control
-
retries (Integer) (defaults to: nil) — Number of times to retry requests on server
error. The default value is
3
. Optional. - timeout (Integer) (defaults to: nil) — (default timeout) The max duration, in seconds, to wait before timing out. Optional. If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
- open_timeout (Integer) (defaults to: nil) — How long, in seconds, before failed connections time out. Optional.
- read_timeout (Integer) (defaults to: nil) — How long, in seconds, before requests time out. Optional.
- send_timeout (Integer) (defaults to: nil) — How long, in seconds, before receiving response from server times out. Optional.
require "google/cloud/storage" storage = Google::Cloud.storage "my-project", "/path/to/keyfile.json" bucket = storage.bucket "my-bucket" file = bucket.file "path/to/my-file.ext"
#storage
def storage(scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: 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.
-
scope (String, Array<String>) (defaults to: nil) —
The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.
The default scope is:
https://www.googleapis.com/auth/devstorage.full_control
-
retries (Integer) (defaults to: nil) — Number of times to retry requests on server
error. The default value is
3
. Optional. - timeout (Integer) (defaults to: nil) — (default timeout) The max duration, in seconds, to wait before timing out. Optional. If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
- open_timeout (Integer) (defaults to: nil) — How long, in seconds, before failed connections time out. Optional.
- read_timeout (Integer) (defaults to: nil) — How long, in seconds, before requests time out. Optional.
- send_timeout (Integer) (defaults to: nil) — How long, in seconds, before receiving response from server times out. Optional.
require "google/cloud" gcloud = Google::Cloud.new storage = gcloud.storage bucket = storage.bucket "my-bucket" file = bucket.file "path/to/my-file.ext"
The default scope can be overridden with the scope
option:
require "google/cloud" gcloud = Google::Cloud.new readonly_scope = "https://www.googleapis.com/auth/devstorage.read_only" readonly_storage = gcloud.storage scope: readonly_scope