changed s3 urls to using the folder convention

This commit is contained in:
Régis Hanol 2013-07-16 23:51:12 +02:00
parent 23a57c8d08
commit f40cad0f4b
3 changed files with 7 additions and 6 deletions

View File

@ -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)

View File

@ -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

View File

@ -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