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.
Parameters
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) —
retries (Integer) (defaults to: nil) — Number of times to retry requests on server
error. The default value is 3. Optional.
max_elapsed_time (Integer) (defaults to: nil) — Total time in seconds that requests are allowed to keep being retried.
base_interval (Float) (defaults to: nil) — The initial interval in seconds between tries.
max_interval (Integer) (defaults to: nil) — The maximum interval in seconds that any individual retry can reach.
multiplier (Integer) (defaults to: nil) — Each successive interval grows by this factor. A multipler of 1.5 means the next
interval will be 1.5x the current interval.
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.
upload_chunk_size (Integer) (defaults to: nil) — The chunk size of storage upload, in bytes.
The default value is 100 MB, i.e. 104_857_600 bytes. To disable chunking and upload
the complete file regardless of size, pass 0 as the chunk size.
retries (Integer) (defaults to: nil) — Number of times to retry requests on server
error. The default value is 3. Optional.
max_elapsed_time (Integer) (defaults to: nil) — Total time in seconds that requests are allowed to keep being retried.
base_interval (Float) (defaults to: nil) — The initial interval in seconds between tries.
max_interval (Integer) (defaults to: nil) — The maximum interval in seconds that any individual retry can reach.
multiplier (Integer) (defaults to: nil) — Each successive interval grows by this factor. A multipler of 1.5 means the next
interval will be 1.5x the current interval.
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.
upload_chunk_size (Integer) (defaults to: nil) — The chunk size of storage upload, in bytes.
The default value is 100 MB, i.e. 104_857_600 bytes. To disable chunking and upload
the complete file regardless of size, pass 0 as the chunk size.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Storage API - Module Google::Cloud (v1.57.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.57.0 (latest)](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud)\n- [1.56.0](/ruby/docs/reference/google-cloud-storage/1.56.0/Google-Cloud)\n- [1.55.0](/ruby/docs/reference/google-cloud-storage/1.55.0/Google-Cloud)\n- [1.54.0](/ruby/docs/reference/google-cloud-storage/1.54.0/Google-Cloud)\n- [1.53.0](/ruby/docs/reference/google-cloud-storage/1.53.0/Google-Cloud)\n- [1.52.0](/ruby/docs/reference/google-cloud-storage/1.52.0/Google-Cloud)\n- [1.51.0](/ruby/docs/reference/google-cloud-storage/1.51.0/Google-Cloud)\n- [1.50.0](/ruby/docs/reference/google-cloud-storage/1.50.0/Google-Cloud)\n- [1.49.0](/ruby/docs/reference/google-cloud-storage/1.49.0/Google-Cloud)\n- [1.48.1](/ruby/docs/reference/google-cloud-storage/1.48.1/Google-Cloud)\n- [1.47.0](/ruby/docs/reference/google-cloud-storage/1.47.0/Google-Cloud)\n- [1.46.0](/ruby/docs/reference/google-cloud-storage/1.46.0/Google-Cloud)\n- [1.45.0](/ruby/docs/reference/google-cloud-storage/1.45.0/Google-Cloud)\n- [1.44.0](/ruby/docs/reference/google-cloud-storage/1.44.0/Google-Cloud)\n- [1.43.0](/ruby/docs/reference/google-cloud-storage/1.43.0/Google-Cloud)\n- [1.42.0](/ruby/docs/reference/google-cloud-storage/1.42.0/Google-Cloud)\n- [1.41.0](/ruby/docs/reference/google-cloud-storage/1.41.0/Google-Cloud)\n- [1.40.0](/ruby/docs/reference/google-cloud-storage/1.40.0/Google-Cloud)\n- [1.39.0](/ruby/docs/reference/google-cloud-storage/1.39.0/Google-Cloud)\n- [1.38.0](/ruby/docs/reference/google-cloud-storage/1.38.0/Google-Cloud)\n- [1.37.0](/ruby/docs/reference/google-cloud-storage/1.37.0/Google-Cloud)\n- [1.36.2](/ruby/docs/reference/google-cloud-storage/1.36.2/Google-Cloud)\n- [1.35.0](/ruby/docs/reference/google-cloud-storage/1.35.0/Google-Cloud) \nReference documentation and code samples for the Cloud Storage API module Google::Cloud.\n\nMethods\n-------\n\n### .storage\n\n def self.storage(project_id = nil, credentials = nil, scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil, max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil, upload_chunk_size: nil) -\u003e Google::Cloud::Storage::Project\n\nCreates a new object for connecting to the Storage service.\nEach call creates a new connection.\n\n\n\u003cbr /\u003e\n\nFor more information on connecting to Google Cloud see the\n[Authentication Guide](./AUTHENTICATION \"Authentication Guide\"). \n**Parameters**\n\n- **project_id** (String) --- Project identifier for the Storage service you are connecting to. If not present, the default project for the credentials is used.\n- **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](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Credentials \"Google::Cloud::Storage::Credentials (class)\"))\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling the\n set of resources and operations that the connection can access. See\n [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scope is:\n - `https://www.googleapis.com/auth/devstorage.full_control`\n- **retries** (Integer) *(defaults to: nil)* --- Number of times to retry requests on server error. The default value is `3`. Optional.\n- **max_elapsed_time** (Integer) *(defaults to: nil)* --- Total time in seconds that requests are allowed to keep being retried.\n- **base_interval** (Float) *(defaults to: nil)* --- The initial interval in seconds between tries.\n- **max_interval** (Integer) *(defaults to: nil)* --- The maximum interval in seconds that any individual retry can reach.\n- **multiplier** (Integer) *(defaults to: nil)* --- Each successive interval grows by this factor. A multipler of 1.5 means the next interval will be 1.5x the current interval.\n- **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.\n- **open_timeout** (Integer) *(defaults to: nil)* --- How long, in seconds, before failed connections time out. Optional.\n- **read_timeout** (Integer) *(defaults to: nil)* --- How long, in seconds, before requests time out. Optional.\n- **send_timeout** (Integer) *(defaults to: nil)* --- How long, in seconds, before receiving response from server times out. Optional.\n- **upload_chunk_size** (Integer) *(defaults to: nil)* --- The chunk size of storage upload, in bytes. The default value is 100 MB, i.e. 104_857_600 bytes. To disable chunking and upload the complete file regardless of size, pass 0 as the chunk size. \n**Returns**\n\n- ([Google::Cloud::Storage::Project](./Google-Cloud-Storage-Project))\n**Example** \n\n```ruby\nrequire \"google/cloud/storage\"\n\nstorage = Google::Cloud.storage \"my-project\",\n \"/path/to/keyfile.json\"\n\nbucket = storage.bucket \"my-bucket\"\nfile = bucket.file \"path/to/my-file.ext\"\n```\n\n### #storage\n\n def storage(scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil, max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil, upload_chunk_size: nil) -\u003e Google::Cloud::Storage::Project\n\nCreates a new object for connecting to the Storage service.\nEach call creates a new connection.\n\n\n\u003cbr /\u003e\n\nFor more information on connecting to Google Cloud see the\n[Authentication Guide](./AUTHENTICATION \"Authentication Guide\"). \n**Parameters**\n\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling the\n set of resources and operations that the connection can access. See\n [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scope is:\n - `https://www.googleapis.com/auth/devstorage.full_control`\n- **retries** (Integer) *(defaults to: nil)* --- Number of times to retry requests on server error. The default value is `3`. Optional.\n- **max_elapsed_time** (Integer) *(defaults to: nil)* --- Total time in seconds that requests are allowed to keep being retried.\n- **base_interval** (Float) *(defaults to: nil)* --- The initial interval in seconds between tries.\n- **max_interval** (Integer) *(defaults to: nil)* --- The maximum interval in seconds that any individual retry can reach.\n- **multiplier** (Integer) *(defaults to: nil)* --- Each successive interval grows by this factor. A multipler of 1.5 means the next interval will be 1.5x the current interval.\n- **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.\n- **open_timeout** (Integer) *(defaults to: nil)* --- How long, in seconds, before failed connections time out. Optional.\n- **read_timeout** (Integer) *(defaults to: nil)* --- How long, in seconds, before requests time out. Optional.\n- **send_timeout** (Integer) *(defaults to: nil)* --- How long, in seconds, before receiving response from server times out. Optional.\n- **upload_chunk_size** (Integer) *(defaults to: nil)* --- The chunk size of storage upload, in bytes. The default value is 100 MB, i.e. 104_857_600 bytes. To disable chunking and upload the complete file regardless of size, pass 0 as the chunk size. \n**Returns**\n\n- ([Google::Cloud::Storage::Project](./Google-Cloud-Storage-Project))\n**Examples** \n\n```ruby\nrequire \"google/cloud\"\n\ngcloud = Google::Cloud.new\nstorage = gcloud.storage\nbucket = storage.bucket \"my-bucket\"\nfile = bucket.file \"path/to/my-file.ext\"\n```\n\nThe default scope can be overridden with the `scope` option: \n\n```ruby\nrequire \"google/cloud\"\n\ngcloud = Google::Cloud.new\nreadonly_scope = \"https://www.googleapis.com/auth/devstorage.read_only\"\nreadonly_storage = gcloud.storage scope: readonly_scope\n```"]]