about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen <eugen@zeonfederated.com>2017-03-24 00:13:08 +0100
committerGitHub <noreply@github.com>2017-03-24 00:13:08 +0100
commit3e2d6ea4083c878e51eb291f2b04d004d3d0ff60 (patch)
tree1502911e9bba9e0d06dfba9b86c51facaa4fa89e
parent08faeedff7838e339488cfcddf02d95241557ffb (diff)
parentc46843c65c0761f97d894f21e361489a0fa1a60a (diff)
Merge pull request #676 from leopku/feature/s3_protocol_from_env
:wrench: S3 protocol  from ENV
-rw-r--r--.env.production.sample2
-rw-r--r--config/initializers/paperclip.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/.env.production.sample b/.env.production.sample
index ef0af9d5c..bd81b8fca 100644
--- a/.env.production.sample
+++ b/.env.production.sample
@@ -39,6 +39,8 @@ SMTP_FROM_ADDRESS=notifications@example.com
 # AWS_ACCESS_KEY_ID=
 # AWS_SECRET_ACCESS_KEY=
 # S3_REGION=
+# S3_PROTOCOL=http
+# S3_HOSTNAME=192.168.1.123:9000
 
 # Optional alias for S3 if you want to use Cloudfront or Cloudflare in front
 # S3_CLOUDFRONT_HOST=
diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb
index 580a3196e..2a2ef8fea 100644
--- a/config/initializers/paperclip.rb
+++ b/config/initializers/paperclip.rb
@@ -11,7 +11,7 @@ if ENV['S3_ENABLED'] == 'true'
   Aws.eager_autoload!(services: %w(S3))
 
   Paperclip::Attachment.default_options[:storage]        = :s3
-  Paperclip::Attachment.default_options[:s3_protocol]    = 'https'
+  Paperclip::Attachment.default_options[:s3_protocol]    = ENV.fetch('S3_PROTOCOL') { 'https' }
   Paperclip::Attachment.default_options[:url]            = ':s3_domain_url'
   Paperclip::Attachment.default_options[:s3_host_name]   = ENV.fetch('S3_HOSTNAME') { "s3-#{ENV.fetch('S3_REGION')}.amazonaws.com" }
   Paperclip::Attachment.default_options[:path]           = '/:class/:attachment/:id_partition/:style/:filename'