Add support for AWS cn (#4327)
This commit is contained in:
parent
e5bbfe1f1b
commit
f8a12d4940
|
@ -20,7 +20,8 @@ class S3RegionSiteSetting < EnumSiteSetting
|
|||
'ap-southeast-2',
|
||||
'ap-northeast-1',
|
||||
'ap-northeast-2',
|
||||
'sa-east-1'
|
||||
'sa-east-1',
|
||||
'cn-north-1'
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -186,6 +186,7 @@ en:
|
|||
ap_northeast_1: "Asia Pacific (Tokyo)"
|
||||
ap_northeast_2: "Asia Pacific (Seoul)"
|
||||
sa_east_1: "South America (Sao Paulo)"
|
||||
cn_north_1: "China (Beijing)"
|
||||
|
||||
edit: 'edit the title and category of this topic'
|
||||
not_implemented: "That feature hasn't been implemented yet, sorry!"
|
||||
|
|
|
@ -132,6 +132,7 @@ zh_CN:
|
|||
ap_northeast_1: "亚洲太平洋(Tokyo)"
|
||||
ap_northeast_2: "亚洲太平洋(Seoul)"
|
||||
sa_east_1: "南美(Sao Paulo)"
|
||||
cn_north_1: "中国 (北京)"
|
||||
edit: '编辑本主题的标题和分类'
|
||||
not_implemented: "非常抱歉,此功能暂时尚未实现!"
|
||||
no_value: "否"
|
||||
|
|
|
@ -62,6 +62,8 @@ module FileStore
|
|||
# cf. http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
|
||||
@absolute_base_url ||= if SiteSetting.s3_region == "us-east-1"
|
||||
"//#{s3_bucket}.s3.amazonaws.com"
|
||||
elsif SiteSetting.s3_region == 'cn-north-1'
|
||||
"//#{s3_bucket}.s3.cn-north-1.amazonaws.com.cn"
|
||||
else
|
||||
"//#{s3_bucket}.s3-#{SiteSetting.s3_region}.amazonaws.com"
|
||||
end
|
||||
|
|
|
@ -81,6 +81,10 @@ describe FileStore::S3Store do
|
|||
|
||||
SiteSetting.stubs(:s3_region).returns("us-east-2")
|
||||
expect(FileStore::S3Store.new(s3_helper).absolute_base_url).to eq("//s3_upload_bucket.s3-us-east-2.amazonaws.com")
|
||||
|
||||
SiteSetting.stubs(:s3_region).returns("cn-north-1")
|
||||
expect(FileStore::S3Store.new(s3_helper).absolute_base_url).to eq("//s3_upload_bucket.s3.cn-north-1.amazonaws.com.cn")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ describe S3RegionSiteSetting do
|
|||
|
||||
describe 'values' do
|
||||
it 'returns all the S3 regions' do
|
||||
expect(S3RegionSiteSetting.values.map {|x| x[:value]}.sort).to eq(['us-east-1', 'us-west-1', 'us-west-2', 'us-gov-west-1', 'eu-west-1', 'eu-central-1', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'ap-northeast-2', 'sa-east-1'].sort)
|
||||
expect(S3RegionSiteSetting.values.map {|x| x[:value]}.sort).to eq(['us-east-1', 'us-west-1', 'us-west-2', 'us-gov-west-1', 'eu-west-1', 'eu-central-1', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'ap-northeast-2', 'sa-east-1', 'cn-north-1'].sort)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue