Permalink
Browse files

Adding S3 config to CarrierWave.

* this configures the app to use S3 once in production on Heroku
  • Loading branch information...
1 parent ca15141 commit f2e945bbc298d0d4423632d7f77be47ddf9820c3 @jonmagic committed Oct 20, 2011
Showing with 13 additions and 2 deletions.
  1. +12 −1 lib/pdf_archive.rb
  2. +1 −1 lib/pdf_uploader.rb
View
13 lib/pdf_archive.rb
@@ -28,8 +28,19 @@ def self.root
# CarrierWave setup
require 'carrierwave/orm/mongomapper'
+CarrierWave.configure do |config|
+ config.fog_credentials = {
+ :provider => 'AWS',
+ :aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
+ :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
+ }
-# require pdf uploader and document model
+ config.fog_directory = ENV['BUCKET_NAME']
+ config.fog_public = true # optional, defaults to true
+ config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
+end
+
+# require pdf uploader, document model, and process pdf job
require 'pdf_uploader'
require 'document'
require 'process_pdf'
View
2 lib/pdf_uploader.rb
@@ -1,6 +1,6 @@
class PdfUploader < CarrierWave::Uploader::Base
Grim::WIDTH = 100
- storage :file
+ storage PdfArchive.environment == "production" ? :fog : :file
def cache_dir
"#{PdfArchive.root}/tmp/cache/#{model.id}"

0 comments on commit f2e945b

Please sign in to comment.