Module: CarrierWave

Defined in:
lib/locomotive/carrierwave/base.rb,
lib/locomotive/carrierwave/patches.rb

Defined Under Namespace

Modules: SafeRemove, Uploader Classes: Mounter

Class Method Summary collapse

Class Method Details

.base_hostObject

This method returns the minimal host of the current storage. For instance, if the chosen storage is AWS S3, then it returns something similar to https://<BUCKET>.s3-<REGION>.amazonaws.com. The returned value is bound to the current storage.

Special case: if the storage is file, then it’ll return nil



10
11
12
13
14
15
16
17
18
19
# File 'lib/locomotive/carrierwave/patches.rb', line 10

def self.base_host
  # don't treat the 'file' storage
  storage_klass = CarrierWave::Uploader::Base.storage.to_s
  return nil if CarrierWave::Uploader::Base.storage_engines.invert[storage_klass] == :file

  uploader = CarrierWave::Uploader::Base.new
  uploader.retrieve_from_store!(nil)

  uploader.url.gsub('/' + uploader.path, '')
end