mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 04:52:45 +08:00
changed s3 urls to using the folder convention
This commit is contained in:
parent
23a57c8d08
commit
f40cad0f4b
|
@ -13,7 +13,7 @@ module S3
|
|||
end
|
||||
|
||||
def self.base_url
|
||||
"//#{SiteSetting.s3_upload_bucket}.s3.amazonaws.com"
|
||||
"//s3.amazonaws.com/#{SiteSetting.s3_upload_bucket}"
|
||||
end
|
||||
|
||||
def self.remove_file(url)
|
||||
|
|
|
@ -17,14 +17,15 @@ describe S3 do
|
|||
let(:image_info) { FastImage.new(file) }
|
||||
|
||||
before(:each) do
|
||||
SiteSetting.stubs(:s3_upload_bucket).returns("s3_upload_bucket")
|
||||
SiteSetting.stubs(:s3_upload_bucket).returns("S3_Upload_Bucket")
|
||||
SiteSetting.stubs(:s3_access_key_id).returns("s3_access_key_id")
|
||||
SiteSetting.stubs(:s3_secret_access_key).returns("s3_secret_access_key")
|
||||
Fog.mock!
|
||||
end
|
||||
|
||||
it 'returns the url of the S3 upload if successful' do
|
||||
S3.store_file(file, "SHA", 1).should == '//s3_upload_bucket.s3.amazonaws.com/1SHA.png'
|
||||
# NOTE: s3 bucket's name are case sensitive so we can't use it as a subdomain...
|
||||
S3.store_file(file, "SHA", 1).should == '//s3.amazonaws.com/S3_Upload_Bucket/1SHA.png'
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
|
|
@ -163,13 +163,13 @@ describe Upload do
|
|||
|
||||
it "identifies S3 uploads" do
|
||||
SiteSetting.stubs(:enable_s3_uploads).returns(true)
|
||||
SiteSetting.stubs(:s3_upload_bucket).returns("bucket")
|
||||
Upload.has_been_uploaded?("//bucket.s3.amazonaws.com/1337.png").should == true
|
||||
SiteSetting.stubs(:s3_upload_bucket).returns("Bucket")
|
||||
Upload.has_been_uploaded?("//s3.amazonaws.com/Bucket/1337.png").should == true
|
||||
end
|
||||
|
||||
it "identifies external urls" do
|
||||
Upload.has_been_uploaded?("http://domain.com/uploads/default/42/0123456789ABCDEF.jpg").should == false
|
||||
Upload.has_been_uploaded?("//bucket.s3.amazonaws.com/1337.png").should == false
|
||||
Upload.has_been_uploaded?("//s3.amazonaws.com/Bucket/1337.png").should == false
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user