mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 14:43:21 +08:00
Revert "Revert "FIX: upload URLs from S3 on subfolder installs""
This reverts commit 26c96e97e5
.
We have no choice but to run this code
This commit is contained in:
parent
26c96e97e5
commit
f5142861e5
|
@ -91,7 +91,7 @@ module FileStore
|
||||||
return url if SiteSetting.Upload.s3_cdn_url.blank?
|
return url if SiteSetting.Upload.s3_cdn_url.blank?
|
||||||
schema = url[/^(https?:)?\/\//, 1]
|
schema = url[/^(https?:)?\/\//, 1]
|
||||||
folder = @s3_helper.s3_bucket_folder_path.nil? ? "" : "#{@s3_helper.s3_bucket_folder_path}/"
|
folder = @s3_helper.s3_bucket_folder_path.nil? ? "" : "#{@s3_helper.s3_bucket_folder_path}/"
|
||||||
url.sub("#{schema}#{absolute_base_url}/#{folder}", "#{SiteSetting.Upload.s3_cdn_url}/")
|
url.sub("#{schema}#{absolute_base_url}/#{folder}", "#{SiteSetting.Upload.s3_cdn_url}#{Discourse.base_uri}/")
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_avatar(avatar, user_id)
|
def cache_avatar(avatar, user_id)
|
||||||
|
|
|
@ -282,4 +282,21 @@ describe FileStore::S3Store do
|
||||||
assert_path("https://hello", nil)
|
assert_path("https://hello", nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.cdn_url' do
|
||||||
|
|
||||||
|
it 'uses the correct path' do
|
||||||
|
url = "//s3-upload-bucket.s3-us-west-2.amazonaws.com/livechat/original/1X/2252ae522257fc537351e47bbdd34698936b6c38.jpeg"
|
||||||
|
expect(store.cdn_url(url)).to end_with('/livechat/original/1X/2252ae522257fc537351e47bbdd34698936b6c38.jpeg')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'supports subfolder' do
|
||||||
|
SiteSetting.s3_upload_bucket = 's3-upload-bucket/livechat/community'
|
||||||
|
GlobalSetting.stubs(:relative_url_root).returns('/community')
|
||||||
|
Discourse.stubs(:base_uri).returns("/community")
|
||||||
|
url = "//s3-upload-bucket.s3-us-west-2.amazonaws.com/livechat/community/original/1X/2252ae522257fc537351e47bbdd34698936b6c38.jpeg"
|
||||||
|
expect(store.cdn_url(url)).to end_with('/livechat/community/original/1X/2252ae522257fc537351e47bbdd34698936b6c38.jpeg')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user