change the default way to config AWS for carrierwave + fix issue #299
This commit is contained in:
parent
05baecad0b
commit
989f608755
@ -10,11 +10,14 @@ CarrierWave.configure do |config|
|
|||||||
|
|
||||||
when :production
|
when :production
|
||||||
# the following configuration works for Amazon S3
|
# the following configuration works for Amazon S3
|
||||||
config.storage = :s3
|
config.storage = :fog
|
||||||
config.s3_access_key_id = ENV['S3_KEY_ID']
|
config.fog_credentials = {
|
||||||
config.s3_secret_access_key = ENV['S3_SECRET_KEY']
|
:provider => 'AWS',
|
||||||
config.s3_bucket = ENV['S3_BUCKET']
|
:aws_access_key_id => ENV['S3_KEY_ID'],
|
||||||
# config.s3_cname = ENV['S3_CNAME'] # optional
|
:aws_secret_access_key => ENV['S3_SECRET_KEY'],
|
||||||
|
:region => 'us-east-1'
|
||||||
|
}
|
||||||
|
config.fog_directory = ENV['S3_BUCKET']
|
||||||
|
|
||||||
else
|
else
|
||||||
# settings for the local filesystem
|
# settings for the local filesystem
|
||||||
|
@ -3,11 +3,7 @@ module CarrierWave
|
|||||||
class Base
|
class Base
|
||||||
|
|
||||||
def to_liquid
|
def to_liquid
|
||||||
{
|
Locomotive::Liquid::Drops::Uploader.new(self)
|
||||||
:url => self.url,
|
|
||||||
:filename => (File.basename(self.url) rescue ''),
|
|
||||||
:size => self.size
|
|
||||||
}.stringify_keys
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
15
lib/locomotive/liquid/drops/uploader.rb
Normal file
15
lib/locomotive/liquid/drops/uploader.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user