Module: CarrierWave::Uploader::Download

Extended by:
ActiveSupport::Concern
Includes:
Cache, Callbacks, Configuration
Included in:
Base
Defined in:
lib/carrierwave/uploader/download.rb

Defined Under Namespace

Classes: RemoteFile

Instance Method Summary collapse

Methods included from Cache

#cache!, #cache_name, #cached?, #retrieve_from_cache!

Methods included from Callbacks

#with_callbacks

Instance Method Details

#download!(uri) ⇒ Object

Caches the file by downloading it from the given URL.

Parameters

url (String)

The URL where the remote file is stored



53
54
55
56
57
58
59
# File 'lib/carrierwave/uploader/download.rb', line 53

def download!(uri)
  unless uri.blank?
    file = RemoteFile.new(uri)
    raise CarrierWave::DownloadError, "trying to download a file which is not served over HTTP" unless file.http?
    cache!(file)
  end
end