about summary refs log tree commit diff
diff options
context:
space:
mode:
authorValentin Lorentz <progval+github@progval.net>2017-04-15 02:07:21 +0200
committerEugen <eugen@zeonfederated.com>2017-04-15 02:07:21 +0200
commit5ab0ffc6c8ae37d95b559ed0a9f2b926490e1d59 (patch)
tree876089bb19da135cee8adff1ca76808a70a7a93c
parent8482f67cafabbd747126238c03853f251e0dce56 (diff)
Custom Paperclip path. (#778)
* Custom Paperclip path.

* Document PAPERCLIP_ROOT.

* Add PAPERCLIP_ROOT_URL (and rename PAPERCLIP_ROOT to PAPERCLIP_ROOT_PATH).
-rw-r--r--.env.production.sample4
-rw-r--r--config/initializers/paperclip.rb3
2 files changed, 7 insertions, 0 deletions
diff --git a/.env.production.sample b/.env.production.sample
index 7c82c014e..fd2f71165 100644
--- a/.env.production.sample
+++ b/.env.production.sample
@@ -41,6 +41,10 @@ SMTP_FROM_ADDRESS=notifications@example.com
 #SMTP_ENABLE_STARTTLS_AUTO=true
 
 
+# Optional user upload path and URL (images, avatars). Default is :rails_root/public/system. If you set this variable, you are responsible for making your HTTP server (eg. nginx) serve these files.
+# PAPERCLIP_ROOT_PATH=/var/lib/mastodon/public-system
+# PAPERCLIP_ROOT_URL=/system
+
 # Optional asset host for multi-server setups
 # CDN_HOST=assets.example.com
 
diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb
index c58f1b06c..202c102c7 100644
--- a/config/initializers/paperclip.rb
+++ b/config/initializers/paperclip.rb
@@ -38,4 +38,7 @@ 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
+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'
 end