Merge pull request #5838 from discourse/fix-for-s3-subfolders

FIX for bucket name in GlobalSetting with folder
This commit is contained in:
Guo Xiang Tan 2018-05-22 18:10:44 +08:00 committed by GitHub
commit f6becd6a4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -85,6 +85,10 @@ class GlobalSetting
end) == :true
end
def self.s3_bucket_name
@s3_bucket_name ||= s3_bucket.downcase.split("/")[0]
end
# for testing
def self.reset_s3_cache!
@use_s3 = nil

View File

@ -133,7 +133,7 @@ class SiteSetting < ActiveRecord::Base
end
def self.absolute_base_url
bucket = SiteSetting.enable_s3_uploads ? Discourse.store.s3_bucket_name : GlobalSetting.s3_bucket
bucket = SiteSetting.enable_s3_uploads ? Discourse.store.s3_bucket_name : GlobalSetting.s3_bucket_name
# cf. http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
if SiteSetting.Upload.s3_region == "us-east-1"