32 lines
1.5 KiB
Ruby
32 lines
1.5 KiB
Ruby
module JamRuby
|
|
|
|
# https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3a-Define-different-storage-configuration-for-each-Uploader.
|
|
|
|
# these methods should be called in initialize() of uploaders to override their configuration
|
|
|
|
class UploaderConfiguration
|
|
def self.set_aws_public_configuration(config)
|
|
config.fog_credentials = {
|
|
:provider => 'AWS',
|
|
:aws_access_key_id => APP_CONFIG.aws_access_key_id,
|
|
:aws_secret_access_key => APP_CONFIG.aws_secret_access_key,
|
|
:region => APP_CONFIG.aws_region,
|
|
}
|
|
config.fog_directory = APP_CONFIG.aws_bucket_public # required
|
|
config.fog_public = true # optional, defaults to true
|
|
config.fog_attributes = {'Cache-Control'=>"max-age=#{APP_CONFIG.aws_cache}"} # optional, defaults to {}
|
|
end
|
|
|
|
def self.set_aws_private_configuration(config)
|
|
config.fog_credentials = {
|
|
:provider => 'AWS',
|
|
:aws_access_key_id => APP_CONFIG.aws_access_key_id,
|
|
:aws_secret_access_key => APP_CONFIG.aws_secret_access_key,
|
|
:region => APP_CONFIG.aws_region,
|
|
}
|
|
config.fog_directory = APP_CONFIG.aws_bucket # required
|
|
config.fog_public = false # optional, defaults to true
|
|
config.fog_attributes = {'Cache-Control'=>"max-age=#{APP_CONFIG.aws_cache}"} # optional, defaults to {}
|
|
end
|
|
end
|
|
end |