Permalink
Browse files

ignore cname & use s3.amazonaws.com w/ ssl enabled

  • Loading branch information...
1 parent 8739df4 commit 269c87c25768697b7bb96e1b30b02bc84a9968c4 Dan Pickett committed Aug 25, 2011
Showing with 15 additions and 3 deletions.
  1. +7 −3 lib/carrierwave/storage/s3.rb
  2. +8 −0 spec/storage/s3_spec.rb
@@ -124,10 +124,14 @@ def url
def public_url
scheme = use_ssl? ? 'https' : 'http'
- if cnamed?
- ["#{scheme}://#{bucket}", path].compact.join('/')
+ if use_ssl?
+ ["#{scheme}://s3.amazonaws.com", "#{bucket}", path].join("/")
else
- ["#{scheme}://#{bucket}.s3.amazonaws.com", path].compact.join('/')
+ if cnamed?
+ ["#{scheme}://#{bucket}", path].compact.join('/')
+ else
+ ["#{scheme}://#{bucket}.s3.amazonaws.com", path].compact.join('/')
+ end
end
end
View
@@ -80,6 +80,14 @@ class S3SpecUploader < CarrierWave::Uploader::Base
@s3_file.url.should == 'http://foo.bar/uploads/bar.txt'
end
end
+
+ context "with ssl enabled" do
+ it "should use the long form of the url with the path" do
+ @uploader.stub!(:s3_bucket).and_return('foo.bar')
+ @uploader.stub!(:s3_use_ssl).and_return(true)
+ @s3_file.url.should == 'https://s3.amazonaws.com/foo.bar/uploads/bar.txt'
+ end
+ end
it "should be deletable" do
@s3_file.delete

0 comments on commit 269c87c

Please sign in to comment.