2012-11-19 19:43:42 +00:00
|
|
|
CarrierWave.configure do |config|
|
2017-04-18 12:28:58 +00:00
|
|
|
if CFG.s3_bucket
|
2012-11-19 19:43:42 +00:00
|
|
|
config.storage = :fog
|
2017-04-18 12:28:58 +00:00
|
|
|
config.fog_directory = CFG.s3_bucket
|
|
|
|
config.fog_public = false
|
2012-11-19 19:43:42 +00:00
|
|
|
|
2012-03-10 16:05:45 +00:00
|
|
|
config.fog_credentials = {
|
2017-04-18 12:28:58 +00:00
|
|
|
provider: 'AWS',
|
|
|
|
aws_access_key_id: CFG.aws_access_key_id,
|
|
|
|
aws_secret_access_key: CFG.aws_secret_access_key,
|
|
|
|
region: CFG.s3_region
|
2012-03-10 16:05:45 +00:00
|
|
|
}
|
2017-04-18 12:28:58 +00:00
|
|
|
else
|
2016-04-10 12:06:48 +00:00
|
|
|
config.root = Rails.root
|
2012-11-19 19:43:42 +00:00
|
|
|
end
|
2012-03-10 16:05:45 +00:00
|
|
|
end
|
2016-04-10 12:06:48 +00:00
|
|
|
|
|
|
|
if File.exists?(Rails.root.to_s + "/public/uploads/asciicast")
|
|
|
|
raise "Please move all directories from ./public/uploads/ to ./uploads/"
|
|
|
|
end
|
2017-01-26 20:43:11 +00:00
|
|
|
|
|
|
|
# fix filename (remove ?AWSAccessKeyId=...)
|
|
|
|
CarrierWave::Storage::Fog::File.class_eval do
|
|
|
|
def filename(options = {})
|
|
|
|
if file_url = url(options)
|
|
|
|
file_url.gsub(/.*\/(.*?$)/, '\1').sub(/\?.*$/, '')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|