Add support for remote OVH cloud storage
This commit is contained in:
parent
b15c2bbb2b
commit
833d7790c2
53 changed files with 243518 additions and 126 deletions
28
config/initializers/carrierwave.rb
Normal file
28
config/initializers/carrierwave.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require_relative 'features'
|
||||
|
||||
Fog.credentials_path = Rails.root.join('config/fog_credentials.yml')
|
||||
|
||||
CarrierWave.configure do |config|
|
||||
# These permissions will make dir and files available only to the user running
|
||||
# the servers
|
||||
config.permissions = 0600
|
||||
config.directory_permissions = 0700
|
||||
|
||||
if Features.remote_storage and not Rails.env.test?
|
||||
config.fog_credentials = { provider: 'OpenStack' }
|
||||
end
|
||||
|
||||
# This avoids uploaded files from saving to public/ and so
|
||||
# they will not be available for public (non-authenticated) downloading
|
||||
config.root = Rails.root
|
||||
|
||||
config.cache_dir = "#{Rails.root}/uploads"
|
||||
|
||||
config.fog_public = true
|
||||
|
||||
if Rails.env.production?
|
||||
config.fog_directory = "tps"
|
||||
else
|
||||
config.fog_directory = "tps_dev"
|
||||
end
|
||||
end
|
26
config/initializers/features.rb
Normal file
26
config/initializers/features.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'yaml'
|
||||
# this class manage features
|
||||
# Features must be added in file config/initializers/features.yml :
|
||||
# feature_name: true
|
||||
# other_feature: false
|
||||
#
|
||||
# this file is templated by ansible for staging and production so don't forget to add your features in
|
||||
# ansible config
|
||||
class Features
|
||||
class << self
|
||||
if File.exist?(File.dirname(__FILE__) + '/features.yml')
|
||||
features_map = YAML.load_file(File.dirname(__FILE__) + '/features.yml')
|
||||
if features_map
|
||||
features_map.each do |feature, is_active|
|
||||
define_method("#{feature}") do
|
||||
is_active
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def method_missing(method, *args)
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue