1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[google|storage] Updates reference to service

This commit is contained in:
Paul Thornthwaite 2012-12-22 23:26:39 +00:00
parent b82eb763f6
commit 59bed55aa0
4 changed files with 15 additions and 15 deletions

View file

@ -10,7 +10,7 @@ module Fog
model Fog::Storage::Google::Directory
def all
data = connection.get_service.body['Buckets']
data = service.get_service.body['Buckets']
load(data)
end
@ -21,7 +21,7 @@ module Fog
:max_keys => 'max-keys',
:prefix => 'prefix'
})
data = connection.get_bucket(key, options).body
data = service.get_bucket(key, options).body
directory = new(:key => data['Name'])
options = {}
for k, v in data

View file

@ -21,7 +21,7 @@ module Fog
def destroy
requires :key
connection.delete_bucket(key)
service.delete_bucket(key)
true
rescue Excon::Errors::NotFound
false
@ -31,7 +31,7 @@ module Fog
@files ||= begin
Fog::Storage::Google::Files.new(
:directory => self,
:connection => connection
:service => service
)
end
end
@ -47,7 +47,7 @@ module Fog
def public_url
requires :key
if connection.get_bucket_acl(key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
if service.get_bucket_acl(key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['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}.storage.googleapis.com"
else
@ -67,7 +67,7 @@ module Fog
if @location
options['LocationConstraint'] = @location
end
connection.put_bucket(key, options)
service.put_bucket(key, options)
true
end

View file

@ -47,15 +47,15 @@ module Fog
def copy(target_directory_key, target_file_key)
requires :directory, :key
connection.copy_object(directory.key, key, target_directory_key, target_file_key)
target_directory = connection.directories.new(:key => target_directory_key)
service.copy_object(directory.key, key, target_directory_key, target_file_key)
target_directory = service.directories.new(:key => target_directory_key)
target_directory.files.get(target_file_key)
end
def destroy
requires :directory, :key
begin
connection.delete_object(directory.key, key)
service.delete_object(directory.key, key)
rescue Excon::Errors::NotFound
end
true
@ -92,7 +92,7 @@ module Fog
def public_url
requires :directory, :key
if connection.get_object_acl(directory.key, key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
if service.get_object_acl(directory.key, key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['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]$/
"https://#{directory.key}.storage.googleapis.com/#{key}"
else
@ -117,7 +117,7 @@ module Fog
options['Expires'] = expires if expires
options.merge(metadata)
data = connection.put_object(directory.key, key, body, options)
data = service.put_object(directory.key, key, body, options)
merge_attributes(data.headers.reject {|key, value| ['Content-Length', 'Content-Type'].include?(key)})
self.content_length = Fog::Storage.get_body_size(body)
self.content_type ||= Fog::Storage.get_content_type(body)

View file

@ -60,7 +60,7 @@ module Fog
def get(key, options = {}, &block)
requires :directory
data = connection.get_object(directory.key, key, options, &block)
data = service.get_object(directory.key, key, options, &block)
file_data = data.headers.merge({
:body => data.body,
:key => key
@ -72,17 +72,17 @@ module Fog
def get_http_url(key, expires)
requires :directory
connection.get_object_http_url(directory.key, key, expires)
service.get_object_http_url(directory.key, key, expires)
end
def get_https_url(key, expires)
requires :directory
connection.get_object_https_url(directory.key, key, expires)
service.get_object_https_url(directory.key, key, expires)
end
def head(key, options = {})
requires :directory
data = connection.head_object(directory.key, key, options)
data = service.head_object(directory.key, key, options)
file_data = data.headers.merge({
:key => key
})