require 'carrierwave'

CarrierWave.root = Rails.root.join(Rails.public_path).to_s
CarrierWave.base_path = ENV['RAILS_RELATIVE_URL_ROOT']

CarrierWave.configure do |config|
  if JamAdmin::Application.config.store_artifacts_to_disk
    config.storage = :file
  else
    config.storage = :fog
    config.fog_credentials = {
        :provider               => 'AWS',
        :aws_access_key_id      => JamAdmin::Application.config.aws_artifact_access_key_id,
        :aws_secret_access_key  => JamAdmin::Application.config.aws_artifact_secret_access_key,
        :region                 => JamAdmin::Application.config.aws_artifact_region,
    }
    config.fog_directory  = JamAdmin::Application.config.aws_artifact_bucket_public                     # required
    config.fog_public     = true                                   # optional, defaults to true
    config.fog_attributes = {'Cache-Control'=>"max-age=#{JamAdmin::Application.config.aws_artifact_cache}"}  # optional, defaults to {}
  end
end

require 'carrierwave/orm/activerecord'


