change the default way to config AWS for carrierwave + fix issue #299

This commit is contained in:
Didier Lafforgue 2012-03-02 01:46:02 +01:00
parent 05baecad0b
commit 989f608755
3 changed files with 24 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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