diff --git a/app/models/upload.rb b/app/models/upload.rb index fedb1ac4f19..9d577f203e9 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -99,7 +99,7 @@ class Upload < ActiveRecord::Base end def self.is_on_s3?(url) - SiteSetting.enable_s3_uploads? && (url.start_with?(S3Store.base_url) || url.start_with?(S3Store.base_url_old)) + SiteSetting.enable_s3_uploads? && url.start_with?(S3Store.base_url) end def self.get_from_url(url) diff --git a/lib/s3_store.rb b/lib/s3_store.rb index a61d311e2ca..3079a9df207 100644 --- a/lib/s3_store.rb +++ b/lib/s3_store.rb @@ -13,10 +13,6 @@ module S3Store end def self.base_url - "//s3.amazonaws.com/#{SiteSetting.s3_upload_bucket}" - end - - def self.base_url_old "//#{SiteSetting.s3_upload_bucket.downcase}.s3.amazonaws.com" end diff --git a/spec/components/s3_store_spec.rb b/spec/components/s3_store_spec.rb index 7fd490e65c5..faa022dfaa7 100644 --- a/spec/components/s3_store_spec.rb +++ b/spec/components/s3_store_spec.rb @@ -25,7 +25,7 @@ describe S3Store do it 'returns the url of the S3 upload if successful' do # NOTE: s3 bucket's name are case sensitive so we can't use it as a subdomain... - S3Store.store_file(file, "SHA", 1).should == '//s3.amazonaws.com/S3_Upload_Bucket/1SHA.png' + S3Store.store_file(file, "SHA", 1).should == '//s3_upload_bucket.s3.amazonaws.com/1SHA.png' end after(:each) do diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index f0a07fcbb63..30333aa1880 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -164,7 +164,7 @@ 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?("//s3.amazonaws.com/Bucket/1337.png").should == true + Upload.has_been_uploaded?("//bucket.s3.amazonaws.com/1337.png").should == true end it "identifies external urls" do @@ -174,24 +174,6 @@ describe Upload do end - context ".is_on_s3?" do - - before do - SiteSetting.stubs(:enable_s3_uploads).returns(true) - SiteSetting.stubs(:s3_upload_bucket).returns("BuCkEt") - end - - it "case-insensitively matches the old subdomain format" do - Upload.is_on_s3?("//bucket.s3.amazonaws.com/1337.png").should == true - end - - it "case-sensitively matches the new folder format" do - Upload.is_on_s3?("//s3.amazonaws.com/BuCkEt/1337.png").should == true - Upload.is_on_s3?("//s3.amazonaws.com/bucket/1337.png").should == false - end - - end - context ".get_from_url" do it "works only when the file has been uploaded" do