Shrine::Storage::GoogleCloudStorage

Provides Google Cloud Storage storage for Shrine.

Installation

gem "shrine-google_cloud_storage"

Authentication

The GCS plugin uses Google's Application Default Credentials. Please check documentation for the various ways to provide credentials.

Usage

require "shrine/storage/gcs"

Shrine.storages = {
  cache: Shrine::Storage::GoogleCloudStorage.new(bucket: "cache"),
  store: Shrine::Storage::GoogleCloudStorage.new(bucket: "store"),
}

You can set a predefined ACL on created objects, as well as custom headers using the object_options parameter:

Shrine::Storage::GoogleCloudStorage.new(
  bucket: "store",
  default_acl: 'publicRead',
  object_options: {
    cache_control: 'public, max-age: 7200'
  },
)

Contributing

Firstly you need to create an .env file with a dedicated GCS bucket:

# .env
GCS_BUCKET="..."

Warning: all content of the bucket is cleared between tests, create a new one only for this usage!

Afterwards you can run the tests:

$ bundle exec rake test

License

MIT