Created
December 18, 2018 06:10
-
-
Save lalitlogical/b0c7f68679b1e32c51fd14bcb22271d0 to your computer and use it in GitHub Desktop.
carrierwave aws
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CarrierWave.configure do |config| | |
if Rails.env.development? or Rails.env.test? | |
config.asset_host = "http://localhost:#{(ENV['PORT'].try(:to_i) || 3000)}" | |
config.storage = :file | |
else | |
config.storage = :aws | |
config.aws_bucket = ENV['S3_BUCKET_NAME'] || "contracts-#{Rails.env}" | |
config.aws_acl = 'public-read' | |
# Optionally define an asset host for configurations that are fronted by a | |
# content host, such as CloudFront. | |
# config.asset_host = 'http://example.com' | |
# The maximum period for authenticated_urls is only 7 days. | |
# config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7 | |
# 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' | |
# } | |
config.aws_credentials = { | |
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'), | |
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'), | |
region: ENV.fetch('AWS_REGION') || 'us-east-1' # Required | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment