mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-22 06:06:45 +00:00
Add S3_KEY_PREFIX
environment variable (#30181)
This commit is contained in:
parent
bc01b328a1
commit
299ae9bf92
|
@ -3,6 +3,8 @@
|
||||||
Paperclip::DataUriAdapter.register
|
Paperclip::DataUriAdapter.register
|
||||||
Paperclip::ResponseWithLimitAdapter.register
|
Paperclip::ResponseWithLimitAdapter.register
|
||||||
|
|
||||||
|
PATH = ':prefix_url:class/:attachment/:id_partition/:style/:filename'
|
||||||
|
|
||||||
Paperclip.interpolates :filename do |attachment, style|
|
Paperclip.interpolates :filename do |attachment, style|
|
||||||
if style == :original
|
if style == :original
|
||||||
attachment.original_filename
|
attachment.original_filename
|
||||||
|
@ -29,7 +31,7 @@ end
|
||||||
|
|
||||||
Paperclip::Attachment.default_options.merge!(
|
Paperclip::Attachment.default_options.merge!(
|
||||||
use_timestamp: false,
|
use_timestamp: false,
|
||||||
path: ':prefix_url:class/:attachment/:id_partition/:style/:filename',
|
path: PATH,
|
||||||
storage: :fog
|
storage: :fog
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,6 +42,8 @@ if ENV['S3_ENABLED'] == 'true'
|
||||||
s3_protocol = ENV.fetch('S3_PROTOCOL') { 'https' }
|
s3_protocol = ENV.fetch('S3_PROTOCOL') { 'https' }
|
||||||
s3_hostname = ENV.fetch('S3_HOSTNAME') { "s3-#{s3_region}.amazonaws.com" }
|
s3_hostname = ENV.fetch('S3_HOSTNAME') { "s3-#{s3_region}.amazonaws.com" }
|
||||||
|
|
||||||
|
Paperclip::Attachment.default_options[:path] = ENV.fetch('S3_KEY_PREFIX') + "/#{PATH}" if ENV.has_key?('S3_KEY_PREFIX')
|
||||||
|
|
||||||
Paperclip::Attachment.default_options.merge!(
|
Paperclip::Attachment.default_options.merge!(
|
||||||
storage: :s3,
|
storage: :s3,
|
||||||
s3_protocol: s3_protocol,
|
s3_protocol: s3_protocol,
|
||||||
|
@ -159,7 +163,7 @@ else
|
||||||
Paperclip::Attachment.default_options.merge!(
|
Paperclip::Attachment.default_options.merge!(
|
||||||
storage: :filesystem,
|
storage: :filesystem,
|
||||||
path: File.join(ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')), ':prefix_path:class', ':attachment', ':id_partition', ':style', ':filename'),
|
path: File.join(ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')), ':prefix_path:class', ':attachment', ':id_partition', ':style', ':filename'),
|
||||||
url: "#{ENV.fetch('PAPERCLIP_ROOT_URL', '/system')}/:prefix_url:class/:attachment/:id_partition/:style/:filename"
|
url: ENV.fetch('PAPERCLIP_ROOT_URL', '/system') + "/#{PATH}"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue