FIX: `Discourse.S3BaseUrl` did not account for subfolder bucket names.
This commit is contained in:
parent
73e30ff4c2
commit
875008522d
|
@ -132,6 +132,11 @@ class SiteSetting < ActiveRecord::Base
|
|||
SiteSetting.enable_s3_uploads || GlobalSetting.use_s3?
|
||||
end
|
||||
|
||||
def self.s3_base_url
|
||||
path = self.s3_upload_bucket.split("/", 2)[1]
|
||||
"#{self.absolute_base_url}#{path ? '/' + path : ''}"
|
||||
end
|
||||
|
||||
def self.absolute_base_url
|
||||
bucket = SiteSetting.enable_s3_uploads ? Discourse.store.s3_bucket_name : GlobalSetting.s3_bucket_name
|
||||
|
||||
|
|
|
@ -84,11 +84,9 @@ class Upload < ActiveRecord::Base
|
|||
|
||||
# when using s3, we need to replace with the absolute base url
|
||||
if SiteSetting.Upload.s3_cdn_url.present?
|
||||
path = Discourse.store.s3_bucket.split("/", 2)[1]
|
||||
|
||||
url = url.sub(
|
||||
SiteSetting.Upload.s3_cdn_url,
|
||||
"#{Discourse.store.absolute_base_url}#{path ? '/' + path : ''}"
|
||||
SiteSetting.Upload.s3_base_url
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<%- if SiteSetting.Upload.s3_cdn_url.present? %>
|
||||
Discourse.S3CDN = '<%= SiteSetting.Upload.s3_cdn_url %>';
|
||||
<%- end %>
|
||||
Discourse.S3BaseUrl = '<%= SiteSetting.Upload.absolute_base_url %>';
|
||||
Discourse.S3BaseUrl = '<%= SiteSetting.Upload.s3_base_url %>';
|
||||
<%- end %>
|
||||
})();
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue