Skip to content

Instantly share code, notes, and snippets.

@framallo
Created January 5, 2016 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save framallo/63019581d5a4e81f8ce3 to your computer and use it in GitHub Desktop.
Save framallo/63019581d5a4e81f8ce3 to your computer and use it in GitHub Desktop.
# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
if Rails.env.production?
config.root = Rails.root.join('tmp')
config.cache_dir = 'carrierwave'
config.storage = :fog
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV['S3_KEY_ID'],
:aws_secret_access_key => ENV['S3_SECRET_KEY'],
:persistent => false # This is required to prevent write timeouts from PUT requests to S3
}
config.fog_directory = ENV['S3_BUCKET']
config.fog_host = ENV['S3_HOST']
config.fog_public = true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # Cache for 1 year
else
config.storage = :file
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment