Allow s3:upload_assets to use site settings from DB take 2.

This commit is contained in:
Guo Xiang Tan 2018-11-15 15:10:39 +08:00
parent c56d682f45
commit 68b640f6a9

View File

@ -37,8 +37,18 @@ def upload(path, remote_path, content_type, content_encoding = nil)
end end
end end
def use_db_s3_config
ENV["USE_DB_S3_CONFIG"]
end
def helper def helper
@helper ||= S3Helper.new(GlobalSetting.s3_bucket.downcase, '', S3Helper.s3_options(GlobalSetting)) @helper ||= begin
setting = use_db_s3_config ? SiteSetting : GlobalSetting
S3Helper.new(
setting.s3_bucket.downcase, '', S3Helper.s3_options(setting)
)
end
end end
def assets def assets
@ -76,7 +86,7 @@ def asset_paths
end end
def ensure_s3_configured! def ensure_s3_configured!
unless GlobalSetting.use_s3? || ENV["USE_DB_S3_CONFIG"] unless GlobalSetting.use_s3? || use_db_s3_config
STDERR.puts "ERROR: Ensure S3 is configured in config/discourse.conf of environment vars" STDERR.puts "ERROR: Ensure S3 is configured in config/discourse.conf of environment vars"
exit 1 exit 1
end end