2019-08-14 09:48:44 +00:00
|
|
|
CarrierWave.configure do |config|
|
2019-10-19 20:11:24 +00:00
|
|
|
config.storage = :file
|
|
|
|
end
|
|
|
|
|
|
|
|
if Rails.env.production?
|
|
|
|
CarrierWave.configure do |config|
|
|
|
|
config.storage = :aws
|
|
|
|
config.aws_bucket = ENV['S3_BUCKET_NAME']
|
|
|
|
config.aws_acl = 'authenticated-read'
|
2019-08-17 20:23:55 +00:00
|
|
|
|
2019-10-19 20:11:24 +00:00
|
|
|
# Optionally define an asset host for configurations that are fronted by a
|
|
|
|
# content host, such as CloudFront.
|
2019-10-20 08:47:26 +00:00
|
|
|
# config.asset_host = 'http://example.com'
|
2019-08-17 20:23:55 +00:00
|
|
|
|
2019-10-19 20:11:24 +00:00
|
|
|
# The maximum period for authenticated_urls is only 7 days.
|
|
|
|
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7
|
2019-08-17 20:23:55 +00:00
|
|
|
|
2019-10-19 20:11:24 +00:00
|
|
|
# Set custom options such as cache control to leverage browser caching
|
|
|
|
config.aws_attributes = {
|
|
|
|
expires: 1.week.from_now.httpdate,
|
|
|
|
cache_control: 'max-age=604800'
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-19 20:11:24 +00:00
|
|
|
config.aws_credentials = {
|
2019-10-20 08:47:26 +00:00
|
|
|
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
2019-10-19 20:11:24 +00:00
|
|
|
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
|
2019-10-20 08:47:26 +00:00
|
|
|
region: ENV['AWS_REGION'] # Required
|
2019-10-19 20:11:24 +00:00
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-19 20:11:24 +00:00
|
|
|
# Optional: Signing of download urls, e.g. for serving private content through
|
|
|
|
# CloudFront. Be sure you have the `cloudfront-signer` gem installed and
|
|
|
|
# configured:
|
|
|
|
# config.aws_signer = -> (unsigned_url, options) do
|
|
|
|
# Aws::CF::Signer.sign_url(unsigned_url, options)
|
|
|
|
# end
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|