mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Make public_url function easier to read and change acl request to deal with nokogiri changes.
This commit is contained in:
parent
ab25d09d94
commit
7fd0fb9f5c
2 changed files with 9 additions and 3 deletions
|
@ -92,7 +92,13 @@ module Fog
|
|||
|
||||
def public_url
|
||||
requires :directory, :key
|
||||
if service.get_object_acl(directory.key, key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
|
||||
|
||||
acl = service.get_object_acl(directory.key, key).body['AccessControlList']
|
||||
access_granted = acl.detect do |entry|
|
||||
entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'
|
||||
end
|
||||
|
||||
if access_granted
|
||||
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}.storage.googleapis.com/#{key}"
|
||||
else
|
||||
|
|
|
@ -17,8 +17,8 @@ module Fog
|
|||
when 'Entries'
|
||||
@in_entries = true
|
||||
when 'Scope'
|
||||
key, value = attrs.first
|
||||
@entry['Scope'][key] = value
|
||||
struct = attrs.first
|
||||
@entry['Scope'][struct.localname] = struct.value
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue