Switch branches/tags
v0.20.0 v0.12.2 v0.12.1 v0.12.0 v0.11.0 v0.10.0 v0.9.0 v0.8.2 v0.8.1 v0.8.0 v0.7.2 v0.7.1 v0.7.0 v0.6.3 v0.6.2 v0.6.1 v0.6.0 v0.5.0 v0.4.1 v0.4.0 v0.3.1 v0.3.0 v0.2.0 v0.1.1 v0.1.0 stackdriver/v0.15.3 stackdriver/v0.15.2 stackdriver/v0.15.1 stackdriver/v0.15.0 stackdriver/v0.14.0 stackdriver/v0.13.0 stackdriver/v0.12.0 stackdriver/v0.11.0 stackdriver/v0.10.0 stackdriver/v0.9.0 stackdriver/v0.8.0 stackdriver/v0.7.0 stackdriver/v0.6.0 stackdriver/v0.5.0 stackdriver/v0.4.1 stackdriver/v0.4.0 stackdriver/v0.3.0 stackdriver-vore/v1.1.0 stackdriver-core/v1.3.3 stackdriver-core/v1.3.2 stackdriver-core/v1.3.1 stackdriver-core/v1.3.0 stackdriver-core/v1.2.0 stackdriver-core/v1.1.0 stackdriver-core/v1.0.0 stackdriver-core/v0.21.0 stackdirver/v0.3.0 google-cloud/v0.56.3 google-cloud/v0.56.2 google-cloud/v0.56.1 google-cloud/v0.56.0 google-cloud/v0.55.0 google-cloud/v0.54.0 google-cloud/v0.53.0 google-cloud/v0.52.0 google-cloud/v0.51.1 google-cloud/v0.51.0 google-cloud/v0.50.0 google-cloud/v0.49.0 google-cloud/v0.48.0 google-cloud/v0.47.0 google-cloud/v0.46.0 google-cloud/v0.45.0 google-cloud/v0.44.0 google-cloud/v0.43.0 google-cloud/v0.42.0 google-cloud/v0.41.0 google-cloud/v0.40.0 google-cloud/v0.39.0 google-cloud/v0.38.0 google-cloud/v0.37.0 google-cloud/v0.36.0 google-cloud/v0.35.0 google-cloud/v0.34.0 google-cloud/v0.33.0 google-cloud/v0.32.0 google-cloud/v0.31.0 google-cloud/v0.30.0 google-cloud/v0.29.0 google-cloud/v0.28.0 google-cloud/v0.27.0 google-cloud/v0.26.0 google-cloud/v0.25.0 google-cloud/v0.24.0 google-cloud/v0.23.0 google-cloud/v0.22.0 google-cloud/v0.21.1 google-cloud/v0.21.0 google-cloud/v0.20.1 google-cloud/v0.20.0 google-cloud-vision/v0.31.0 google-cloud-vision/v0.30.4 google-cloud-vision/v0.30.3 google-cloud-vision/v0.30.2 google-cloud-vision/v0.30.1
Nothing to show
Find file History
quartzmo Release google-cloud-storage 1.15.0
* Add Bucket retention policy
  * Add retention_policy fields and default_event_based_hold to Bucket.
  * Add retention_policy and hold fields to File.
  * Add Bucket#lock_retention_policy!
  * Add Bucket#metageneration.
  * Add Bucket#retention_policy_locked?
  * Add File#(set|release)_temporary_hold!
  * Add File#(set|release)_event_based_hold!
Latest commit 1492643 Oct 3, 2018



Google Cloud Storage (docs) allows you to store data on Google infrastructure with very high reliability, performance and availability, and can be used to distribute large data objects to users via direct download.

Quick Start

$ gem install google-cloud-storage


This library uses Service Account credentials to connect to Google Cloud services. When running on Compute Engine the credentials will be discovered automatically. When running on other environments the Service Account credentials can be specified by providing the path to the JSON file, or the JSON itself, in environment variables.

Instructions and configuration options are covered in the Authentication Guide.


require "google/cloud/storage"

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

bucket = storage.bucket "task-attachments"

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

# Download the file to the local file system
file.download "/tasks/attachments/#{file.name}"

# Copy the file to a backup bucket
backup = storage.bucket "task-attachment-backups"
file.copy backup, file.name

Enabling Logging

To enable logging for this library, set the logger for the underlying Google API Client library. The logger that you set may be a Ruby stdlib Logger as shown below, or a Google::Cloud::Logging::Logger that will write logs to Stackdriver Logging.

If you do not set the logger explicitly and your application is running in a Rails environment, it will default to Rails.logger. Otherwise, if you do not set the logger and you are not using Rails, logging is disabled by default.

Configuring a Ruby stdlib logger:

require "logger"

my_logger = Logger.new $stderr
my_logger.level = Logger::WARN

# Set the Google API Client logger
Google::Apis.logger = my_logger

Supported Ruby Versions

This library is supported on Ruby 2.3+.

Google provides official support for Ruby versions that are actively supported by Ruby Core—that is, Ruby versions that are either in normal maintenance or in security maintenance, and not end of life. Currently, this means Ruby 2.3 and later. Older versions of Ruby may still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby support schedule.


This library follows Semantic Versioning.


Contributions to this library are always welcome and highly encouraged.

See the Contributing Guide for more information on how to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Code of Conduct for more information.


This library is licensed under Apache 2.0. Full license text is available in LICENSE.


Please report bugs at the project on Github. Don't hesitate to ask questions about the client or APIs on StackOverflow.