Module: CarrierWave::Uploader::Download

Defined in:
lib/carrierwave/uploader/download.rb

Defined Under Namespace

Classes: RemoteFile

Instance Method Summary collapse

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



48
49
50
51
52
53
54
# File 'lib/carrierwave/uploader/download.rb', line 48

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