now using fog for cloud storage (s3)

This commit is contained in:
Espen Antonsen 2011-04-12 12:35:42 +08:00
parent 5fb0b945cc
commit 5da472e772
3 changed files with 10 additions and 6 deletions

View file

@ -8,7 +8,7 @@ class FileUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader # Choose what kind of storage to use for this uploader
if ENV['S3_KEY'] if ENV['S3_KEY']
storage :s3 storage :fog
def cache_dir def cache_dir
"#{RAILS_ROOT}/tmp/uploads" if ENV['HEROKU'] == 'true' "#{RAILS_ROOT}/tmp/uploads" if ENV['HEROKU'] == 'true'

View file

@ -11,4 +11,4 @@
<%= form.label :description %><br /> <%= form.label :description %><br />
<%= form.text_area :description %><br /> <%= form.text_area :description %><br />
<br/> <br/>
<p>On disk: ~/<%= @photo.file.file.file %></p> <p>On disk: ~/<%= @photo.file.path %></p>

View file

@ -1,5 +1,9 @@
CarrierWave.configure do |config| CarrierWave.configure do |config|
config.s3_access_key_id = ENV['S3_KEY'] config.fog_credentials = {
config.s3_secret_access_key = ENV['S3_SECRET'] :provider => 'AWS',
config.s3_bucket = ENV['S3_BUCKET'] :aws_access_key_id => ENV['S3_KEY'],
end :aws_secret_access_key => ENV['S3_SECRET'],
:region => 'us-east-1'
}
config.fog_directory = ENV['S3_BUCKET']
end