diff --git a/lib/generators/locomotive/install/templates/carrierwave.rb b/lib/generators/locomotive/install/templates/carrierwave.rb index 5cb02167..42864daa 100644 --- a/lib/generators/locomotive/install/templates/carrierwave.rb +++ b/lib/generators/locomotive/install/templates/carrierwave.rb @@ -10,11 +10,14 @@ CarrierWave.configure do |config| when :production # the following configuration works for Amazon S3 - config.storage = :s3 - config.s3_access_key_id = ENV['S3_KEY_ID'] - config.s3_secret_access_key = ENV['S3_SECRET_KEY'] - config.s3_bucket = ENV['S3_BUCKET'] - # config.s3_cname = ENV['S3_CNAME'] # optional + config.storage = :fog + config.fog_credentials = { + :provider => 'AWS', + :aws_access_key_id => ENV['S3_KEY_ID'], + :aws_secret_access_key => ENV['S3_SECRET_KEY'], + :region => 'us-east-1' + } + config.fog_directory = ENV['S3_BUCKET'] else # settings for the local filesystem diff --git a/lib/locomotive/carrierwave/base.rb b/lib/locomotive/carrierwave/base.rb index c64a620c..a86b6252 100644 --- a/lib/locomotive/carrierwave/base.rb +++ b/lib/locomotive/carrierwave/base.rb @@ -3,11 +3,7 @@ module CarrierWave class Base def to_liquid - { - :url => self.url, - :filename => (File.basename(self.url) rescue ''), - :size => self.size - }.stringify_keys + Locomotive::Liquid::Drops::Uploader.new(self) end end diff --git a/lib/locomotive/liquid/drops/uploader.rb b/lib/locomotive/liquid/drops/uploader.rb new file mode 100644 index 00000000..e6cda0a1 --- /dev/null +++ b/lib/locomotive/liquid/drops/uploader.rb @@ -0,0 +1,15 @@ +module Locomotive + module Liquid + module Drops + class Uploader < Base + + delegate :url, :size, :to => '_source' + + def filename + File.basename(self._source.url) + end + + end + end + end +end \ No newline at end of file