class CarrierWave::Storage::Gcloud

Public Class Methods

clear_connection_cache!() click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 10
def self.clear_connection_cache!
  @connection_cache = {}
end
connection_cache() click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 6
def self.connection_cache
  @connection_cache ||= {}
end

Public Instance Methods

cache!(file) click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 24
def cache!(file)
  GcloudFile.new(uploader, connection, uploader.cache_path).tap do |gcloud_file|
    gcloud_file.store(file)
  end
end
clean_cache!(_seconds) click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 38
def clean_cache!(_seconds)
  raise 'use Object Lifecycle Management to clean the cache'
end
connection() click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 42
def connection
  @connection ||= begin
    conn_cache = self.class.connection_cache
    ENV['SSL_CERT_FILE'] = cert_path
    conn_cache[credentials] ||= ::Google::Cloud.new(
      credentials[:gcloud_project] || ENV['GCLOUD_PROJECT'],
      credentials[:gcloud_keyfile] || ENV['GCLOUD_KEYFILE']
    ).storage
  end
end
credentials() click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 53
def credentials
  uploader.gcloud_credentials || {}
end
delete_dir!(path) click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 34
def delete_dir!(path)
  # do nothing, because there's no such things as 'empty directory'
end
retrieve!(identifier) click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 20
def retrieve!(identifier)
  GcloudFile.new(uploader, connection, uploader.store_path(identifier))
end
retrieve_from_cache!(identifier) click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 30
def retrieve_from_cache!(identifier)
  GcloudFile.new(uploader, connection, uploader.cache_path(identifier))
end
store!(file) click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 14
def store!(file)
  GcloudFile.new(uploader, connection, uploader.store_path).tap do |gcloud_file|
    gcloud_file.store(file)
  end
end

Private Instance Methods

cert_path() click to toggle source
# File lib/carrierwave/storage/gcloud.rb, line 59
def cert_path
  @cert_path ||= begin
    gem_path = Gem.loaded_specs['google-api-client'].full_gem_path
    gem_path + '/lib/cacerts.pem'
  end
end