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:
parent
b82eb763f6
commit
59bed55aa0
4 changed files with 15 additions and 15 deletions
|
@ -10,7 +10,7 @@ module Fog
|
||||||
model Fog::Storage::Google::Directory
|
model Fog::Storage::Google::Directory
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.get_service.body['Buckets']
|
data = service.get_service.body['Buckets']
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Fog
|
||||||
:max_keys => 'max-keys',
|
:max_keys => 'max-keys',
|
||||||
:prefix => 'prefix'
|
:prefix => 'prefix'
|
||||||
})
|
})
|
||||||
data = connection.get_bucket(key, options).body
|
data = service.get_bucket(key, options).body
|
||||||
directory = new(:key => data['Name'])
|
directory = new(:key => data['Name'])
|
||||||
options = {}
|
options = {}
|
||||||
for k, v in data
|
for k, v in data
|
||||||
|
|
|
@ -21,7 +21,7 @@ module Fog
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :key
|
requires :key
|
||||||
connection.delete_bucket(key)
|
service.delete_bucket(key)
|
||||||
true
|
true
|
||||||
rescue Excon::Errors::NotFound
|
rescue Excon::Errors::NotFound
|
||||||
false
|
false
|
||||||
|
@ -31,7 +31,7 @@ module Fog
|
||||||
@files ||= begin
|
@files ||= begin
|
||||||
Fog::Storage::Google::Files.new(
|
Fog::Storage::Google::Files.new(
|
||||||
:directory => self,
|
:directory => self,
|
||||||
:connection => connection
|
:service => service
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -47,7 +47,7 @@ module Fog
|
||||||
|
|
||||||
def public_url
|
def public_url
|
||||||
requires :key
|
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]$/
|
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"
|
"https://#{key}.storage.googleapis.com"
|
||||||
else
|
else
|
||||||
|
@ -67,7 +67,7 @@ module Fog
|
||||||
if @location
|
if @location
|
||||||
options['LocationConstraint'] = @location
|
options['LocationConstraint'] = @location
|
||||||
end
|
end
|
||||||
connection.put_bucket(key, options)
|
service.put_bucket(key, options)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -47,15 +47,15 @@ module Fog
|
||||||
|
|
||||||
def copy(target_directory_key, target_file_key)
|
def copy(target_directory_key, target_file_key)
|
||||||
requires :directory, :key
|
requires :directory, :key
|
||||||
connection.copy_object(directory.key, key, target_directory_key, target_file_key)
|
service.copy_object(directory.key, key, target_directory_key, target_file_key)
|
||||||
target_directory = connection.directories.new(:key => target_directory_key)
|
target_directory = service.directories.new(:key => target_directory_key)
|
||||||
target_directory.files.get(target_file_key)
|
target_directory.files.get(target_file_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :directory, :key
|
requires :directory, :key
|
||||||
begin
|
begin
|
||||||
connection.delete_object(directory.key, key)
|
service.delete_object(directory.key, key)
|
||||||
rescue Excon::Errors::NotFound
|
rescue Excon::Errors::NotFound
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
|
@ -92,7 +92,7 @@ module Fog
|
||||||
|
|
||||||
def public_url
|
def public_url
|
||||||
requires :directory, :key
|
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]$/
|
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}"
|
"https://#{directory.key}.storage.googleapis.com/#{key}"
|
||||||
else
|
else
|
||||||
|
@ -117,7 +117,7 @@ module Fog
|
||||||
options['Expires'] = expires if expires
|
options['Expires'] = expires if expires
|
||||||
options.merge(metadata)
|
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)})
|
merge_attributes(data.headers.reject {|key, value| ['Content-Length', 'Content-Type'].include?(key)})
|
||||||
self.content_length = Fog::Storage.get_body_size(body)
|
self.content_length = Fog::Storage.get_body_size(body)
|
||||||
self.content_type ||= Fog::Storage.get_content_type(body)
|
self.content_type ||= Fog::Storage.get_content_type(body)
|
||||||
|
|
|
@ -60,7 +60,7 @@ module Fog
|
||||||
|
|
||||||
def get(key, options = {}, &block)
|
def get(key, options = {}, &block)
|
||||||
requires :directory
|
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({
|
file_data = data.headers.merge({
|
||||||
:body => data.body,
|
:body => data.body,
|
||||||
:key => key
|
:key => key
|
||||||
|
@ -72,17 +72,17 @@ module Fog
|
||||||
|
|
||||||
def get_http_url(key, expires)
|
def get_http_url(key, expires)
|
||||||
requires :directory
|
requires :directory
|
||||||
connection.get_object_http_url(directory.key, key, expires)
|
service.get_object_http_url(directory.key, key, expires)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_https_url(key, expires)
|
def get_https_url(key, expires)
|
||||||
requires :directory
|
requires :directory
|
||||||
connection.get_object_https_url(directory.key, key, expires)
|
service.get_object_https_url(directory.key, key, expires)
|
||||||
end
|
end
|
||||||
|
|
||||||
def head(key, options = {})
|
def head(key, options = {})
|
||||||
requires :directory
|
requires :directory
|
||||||
data = connection.head_object(directory.key, key, options)
|
data = service.head_object(directory.key, key, options)
|
||||||
file_data = data.headers.merge({
|
file_data = data.headers.merge({
|
||||||
:key => key
|
:key => key
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue