I have both public and private files which I server from Amazon cloudfront, the public files work fine but now I\'d like to secure some of them as private with an authentica
You can setup carrierwave config in separate uploader. like this.
using gem 'aws-sdk', '~> 2.10' gem 'carrierwave-aws', '~> 1.1'
class BusinessDocumentUploader < CarrierWave::Uploader::Base
def initialize(*)
super
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = Rails.application.secrets.aws_bucket
config.aws_acl = 'private'
#acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
# Optionally define an asset host for configurations that are fronted by a
# content host, such as CloudFront.
config.asset_host = Rails.application.secrets.aws_asset_host
# The maximum period for authenticated_urls is only 7 days.
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7
# config.aws_authenticated_url_expiration = 2
# 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: Rails.application.secrets.aws_access_key_id,
secret_access_key: Rails.application.secrets.aws_secret_access_key,
region: Rails.application.secrets.aws_region # Required
}
end
end
end