Module: CarrierWave::EasyEncryption::Downloader

Defined in:
lib/carrierwave_easy_encryption.rb

Class Method Summary collapse

Class Method Details

.download(uploader) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/carrierwave_easy_encryption.rb', line 33

def download(uploader)
  cipher = Gibberish::AES.new(CarrierWave::EasyEncryption.configuration.password)

  is_local = (uploader._storage == CarrierWave::Storage::File)
  istream = open(is_local ? uploader.path : uploader.url)
  ostream = StringIO.new
  cipher.decrypt_stream(istream, ostream)
  return ostream
end