diff options
author | Adam Thurlow <thurloat@gmail.com> | 2017-09-05 18:17:06 -0300 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-09-05 23:17:06 +0200 |
commit | 6994664a1391d6a027caec3d5ca9e022f41a0711 (patch) | |
tree | f0ecba66e42c7eac50f079365c416fc28b3b7d52 /config/initializers | |
parent | be7ffa2d7539d5a1946a3933cb9d242b9fac0ddc (diff) |
swift-enable the paperclip! :paperclip: (#2322)
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/ostatus.rb | 1 | ||||
-rw-r--r-- | config/initializers/paperclip.rb | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/config/initializers/ostatus.rb b/config/initializers/ostatus.rb index a885545f8..c00aba0de 100644 --- a/config/initializers/ostatus.rb +++ b/config/initializers/ostatus.rb @@ -12,6 +12,7 @@ Rails.application.configure do config.x.web_domain = web_host config.x.use_https = https config.x.use_s3 = ENV['S3_ENABLED'] == 'true' + config.x.use_swift = ENV['SWIFT_ENABLED'] == 'true' config.x.alternate_domains = alternate_domains.split(/\s*,\s*/) diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 740c1a953..e9f455251 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -40,6 +40,21 @@ if ENV['S3_ENABLED'] == 'true' Paperclip::Attachment.default_options[:url] = ':s3_alias_url' Paperclip::Attachment.default_options[:s3_host_alias] = ENV['S3_CLOUDFRONT_HOST'] end +elsif ENV['SWIFT_ENABLED'] == 'true' + Paperclip::Attachment.default_options.merge!( + path: ':class/:attachment/:id_partition/:style/:filename', + storage: :fog, + fog_credentials: { + provider: 'OpenStack', + openstack_username: ENV.fetch('SWIFT_USERNAME'), + openstack_tenant: ENV.fetch('SWIFT_TENANT'), + openstack_api_key: ENV.fetch('SWIFT_PASSWORD'), + openstack_auth_url: ENV.fetch('SWIFT_AUTH_URL'), + }, + fog_directory: ENV.fetch('SWIFT_CONTAINER'), + fog_host: ENV.fetch('SWIFT_OBJECT_URL'), + fog_public: true + ) else Paperclip::Attachment.default_options[:path] = (ENV['PAPERCLIP_ROOT_PATH'] || ':rails_root/public/system') + '/:class/:attachment/:id_partition/:style/:filename' Paperclip::Attachment.default_options[:url] = (ENV['PAPERCLIP_ROOT_URL'] || '/system') + '/:class/:attachment/:id_partition/:style/:filename' |