use path style access for https public_urls that include . to avoid certificate issues

closes #743
This commit is contained in:
geemus 2012-02-17 17:07:18 -06:00
parent 6a89912cff
commit 80ca32bfdd
2 changed files with 2 additions and 2 deletions

View File

@ -91,7 +91,7 @@ module Fog
def public_url
requires :key
if connection.get_bucket_acl(key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
if key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
if key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\-(?![\.])){1,61}[a-z0-9]$/
"https://#{key}.s3.amazonaws.com"
else
"https://s3.amazonaws.com/#{key}"

View File

@ -95,7 +95,7 @@ module Fog
def public_url
requires :directory, :key
if connection.get_object_acl(directory.key, key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
if directory.key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
if directory.key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\-(?![\.])){1,61}[a-z0-9]$/
"https://#{directory.key}.s3.amazonaws.com/#{Fog::AWS.escape(key)}"
else
"https://s3.amazonaws.com/#{directory.key}/#{Fog::AWS.escape(key)}"