Method: Fog::Storage::AWS::Directory#public_url

Defined in:
lib/fog/aws/models/storage/directory.rb

#public_urlObject

[View source]

86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/fog/aws/models/storage/directory.rb', line 86

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]$/
      "https://#{key}.s3.amazonaws.com"
    else
      "https://s3.amazonaws.com/#{key}"
    end
  else
    nil
  end
end