about summary refs log tree commit diff
path: root/config/initializers/paperclip.rb
diff options
context:
space:
mode:
authorbeatrix <beatrix.bitrot@gmail.com>2017-09-09 20:11:48 -0400
committerGitHub <noreply@github.com>2017-09-09 20:11:48 -0400
commit3dff74eecf5387b92b862893248710d2efb90eec (patch)
tree0d29d8c952a0c62e7de4348a1d63963fd5eca237 /config/initializers/paperclip.rb
parente18ed4bbc7ab4e258d05a3e2a5db0790f67a8f37 (diff)
parent14e1fb8d36763e5255e7b8e440ecaf02208db004 (diff)
Merge pull request #141 from yipdw/sync/upstream
Sync with upstream @ v1.6.0rc3

ohhhhhhhhhhh heck here we go
Diffstat (limited to 'config/initializers/paperclip.rb')
-rw-r--r--config/initializers/paperclip.rb15
1 files changed, 15 insertions, 0 deletions
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'