1.62.2 (latest) 1.62.1 1.61.0 1.60.0 1.59.0 1.58.0 1.57.1 1.56.0 1.55.0 1.54.0 1.53.0 1.52.0 1.51.0 1.50.0 1.49.0 1.48.1 1.47.0 1.46.0 1.45.0 1.44.0 1.43.0 1.42.0 1.41.0 1.40.0 1.39.0 1.38.0 1.37.0 1.36.2 1.35.0 Reference documentation and code samples for the Cloud Storage API module Google::Cloud::Storage.

## 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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest.md.txt "Storage Overview").

## Methods

### .anonymous

```ruby
def self.anonymous(retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil, endpoint: nil, max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil, upload_chunk_size: nil, universe_domain: nil) -> Google::Cloud::Storage::Project
```
Creates an unauthenticated, anonymous client for retrieving public data
from the Storage service. Each call creates a new connection.
**Parameters**

- **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.
- **endpoint** (String) *(defaults to: nil)* --- Override of the endpoint host name. Optional. If the param is nil, uses the default endpoint.
- **universe_domain** (String) *(defaults to: nil)* --- Override of the universe domain. Optional. If unset or nil, uses the default unvierse domain
- **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.
**Returns**

- ([Google::Cloud::Storage::Project](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Project.md.txt))
**Example**

Use `skip_lookup` to avoid retrieving non-public metadata:

```ruby
require "google/cloud/storage"

storage = Google::Cloud::Storage.anonymous

bucket = storage.bucket "public-bucket", skip_lookup: true
file = bucket.file "path/to/public-file.ext", skip_lookup: true

downloaded = file.download
downloaded.rewind
downloaded.read #=> "Hello world!"
```

### .configure

```ruby
def self.configure() -> 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 parameter `project` 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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Credentials.md.txt "Google::Cloud::Storage::Credentials (class)")) (The parameter `keyfile` is considered deprecated, but may also be used.)
- `endpoint` - (String) Override of the endpoint host name, or `nil` to use the default endpoint.
- `scope` - (String, Array
- `retries` - (Integer) Number of times to retry requests on server error.
- `max_elapsed_time` - (Integer) Total time in seconds that requests are allowed to keep being retried.
- `base_interval` - (Float) The initial interval in seconds between tries.
- `max_interval` - (Integer) The maximum interval in seconds that any individual retry can reach.
- `multiplier` - (Integer) 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) (default timeout) The max duration, in seconds, to wait before timing out. If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
- `open_timeout` - (Integer) How long, in seconds, before failed connections time out.
- `read_timeout` - (Integer) How long, in seconds, before requests time out.
- `send_timeout` - (Integer) How long, in seconds, before receiving response from server times out.
- `upload_chunk_size` - (Integer) The chunk size of storage upload, in bytes.
**Yields**

- (Google::Cloud.configure.storage)
**Returns**

- (Google::Cloud::Config) --- The configuration object the Google::Cloud::Storage library uses.

### .new

```ruby
def self.new(project_id: nil, credentials: nil, scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil, endpoint: nil, project: nil, keyfile: nil, max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil, upload_chunk_size: nil, universe_domain: 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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/AUTHENTICATION.md.txt "Authentication Guide").

<br />

rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
**Parameters**

- **project_id** (String) *(defaults to: nil)* --- Project identifier for the Storage service you are connecting to. If not present, the default project for the credentials is used.
- **credentials** (Google::Auth::Credentials) *(defaults to: nil)* --- A Google::Auth::Credentials object. (See [Credentials](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Credentials.md.txt "Google::Cloud::Storage::Credentials (class)"))
- **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](https://developers.google.com/identity/protocols/OAuth2).

  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.
- **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.
- **endpoint** (String) *(defaults to: nil)* --- Override of the endpoint host name. Optional. If the param is nil, uses the default endpoint.
- **universe_domain** (String) *(defaults to: nil)* --- Override of the universe domain. Optional. If unset or nil, uses the default unvierse domain
- **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.
- **project** (String) *(defaults to: nil)* --- Alias for the `project_id` argument. Deprecated.
- **keyfile** (String) *(defaults to: nil)* --- Alias for the `credentials` argument. Deprecated.
**Returns**

- ([Google::Cloud::Storage::Project](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Project.md.txt))
**Raises**

- (ArgumentError)
**Example**

```ruby
require "google/cloud/storage"

storage = Google::Cloud::Storage.new(
  project_id: "my-project",
  credentials: "/path/to/keyfile.json"
)

bucket = storage.bucket "my-bucket"
file = bucket.file "path/to/my-file.ext"
```

## Constants

### GOOGLEAPIS_URL

**value:**"https://storage.googleapis.com".freeze

### VERSION

**value:**"1.62.2".freeze