Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: carrierwaveuploader/carrierwave
...
head fork: carrierwaveuploader/carrierwave
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 4 commit comments
  • 2 contributors
Commits on Sep 22, 2012
@DouweM DouweM Also use AWS S3 subdomain URL when directory name contains a period. af1a2d3
Commits on Sep 24, 2012
@thiagofm thiagofm Merge pull request #809 from DouweM/s3-subdomain
Also use AWS S3 subdomain URL when directory name contains a period.
56592f3
Showing with 15 additions and 1 deletion.
  1. +1 −1  lib/carrierwave/storage/fog.rb
  2. +14 −0 spec/storage/fog_helper.rb
View
2  lib/carrierwave/storage/fog.rb
@@ -286,7 +286,7 @@ def public_url
case @uploader.fog_credentials[:provider]
when 'AWS'
# if directory is a valid subdomain, use that style for access
- if @uploader.fog_directory.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\d{1,3}){3}$))(?:[a-z0-9]|(?![\-])|\-(?![\.])){1,61}[a-z0-9]$/
+ if @uploader.fog_directory.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\d{1,3}){3}$))(?:[a-z0-9\.]|(?![\-])|\-(?![\.])){1,61}[a-z0-9]$/
"https://#{@uploader.fog_directory}.s3.amazonaws.com/#{path}"
else
# directory is not a valid subdomain, so use path style for access
View
14 spec/storage/fog_helper.rb
@@ -69,6 +69,20 @@ class FogSpec#{fog_credentials[:provider]}Uploader < CarrierWave::Uploader::Base
@fog_file.url.should_not be_nil
end
end
+
+ it "should use a subdomain URL for AWS if the directory is a valid subdomain" do
+ if @provider == 'AWS'
+ @uploader.stub(:fog_directory).and_return('assets.site.com')
+ @fog_file.public_url.should include('https://assets.site.com.s3.amazonaws.com')
+ end
+ end
+
+ it "should not use a subdomain URL for AWS if the directory is not a valid subdomain" do
+ if @provider == 'AWS'
+ @uploader.stub(:fog_directory).and_return('SiteAssets')
+ @fog_file.public_url.should include('https://s3.amazonaws.com/SiteAssets')
+ end
+ end
end
context "with asset_host" do

Showing you all comments on commits in this comparison.

@rymai

Actually, I think this was intentional since it's causing a SSL warning when a subdomain contains period(s).

@DouweM

Hmm. I've been using this for the last 8 months now and haven't had any problems. Note that the old way wasn't working at all, because the subdomain style is required for buckets outside of the US Standard zone. See the PR that introduced this commit: #809.

@rymai

I see... For now the better trade-off is then to not have bucket names with period I guess.

@DouweM

Unfortunately there's no way around bucket names with periods if you want to have your bucket accessible through a whitelabel URL such as assets.domain.com. In this case, your bucket has to be named "assets.domain.com" and CarrierWave has to connect to assets.domain.com.s3.amazonaws.com, even though this causes issues with SSL.

Something went wrong with that request. Please try again.