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

Merge branch 'master' of git@github.com:geemus/fog

This commit is contained in:
Wesley Beary 2009-08-19 20:33:10 -07:00
commit 37c8ce7bd7
3 changed files with 39 additions and 52 deletions

View file

@ -5,9 +5,9 @@ module Fog
class Bucket < Fog::Model
attr_accessor :creation_date,
:location,
:name,
:owner
:location,
:name,
:owner
def initialize(attributes = {})
remap_attributes(attributes, {
@ -22,10 +22,8 @@ module Fog
end
def location
@location ||= begin
data = s3.get_bucket_location(name)
data.body['LocationConstraint']
end
data = s3.get_bucket_location(name)
data.body['LocationConstraint']
end
def objects
@ -36,10 +34,8 @@ module Fog
end
def payer
@payer ||= begin
data = connection.get_request_payment(name)
data.body['Payer']
end
data = connection.get_request_payment(name)
data.body['Payer']
end
def payer=(new_payer)

View file

@ -6,6 +6,7 @@ module Fog
attr_accessor :body,
:content_length,
:content_type,
:etag,
:key,
:last_modified,
@ -26,14 +27,6 @@ module Fog
super
end
def body
@body ||= get.body
end
def content_length
@content_length ||= head.content_length
end
def copy(target_bucket_name, target_object_key)
data = connection.copy_object(bucket.name, key, target_bucket_name, target_object_key).body
copy = self.dup
@ -51,14 +44,6 @@ module Fog
connection.delete_object(bucket, key)
end
def etag
@etag ||= head.etag
end
def last_modified
@last_modified ||= head.last_modified
end
def save(options = {})
data = connection.put_object(bucket.name, key, body, options)
@etag = data.headers['ETag']
@ -66,28 +51,6 @@ module Fog
private
def get
data = connection.get_object(bucket.name, key, options)
object_data = { :body => data.body}
for key, value in data.headers
if ['Content-Length', 'ETag', 'Last-Modified'].include?(key)
object_data[key] = value
end
end
update_attributes(object_data)
end
def head
data = connection.head_object(bucket.name, key, options)
object_data = {}
for key, value in data.headers
if ['Content-Length', 'ETag', 'Last-Modified'].include?(key)
object_data[key] = value
end
end
update_attributes(object_data)
end
def bucket=(new_bucket)
@bucket = new_bucket
end

View file

@ -34,9 +34,9 @@ module Fog
data['Contents'].each do |object|
owner = Fog::AWS::S3::Owner.new(object.delete('Owner').merge!(:connection => connection))
objects << Fog::AWS::S3::Object.new({
:bucket => bucket,
:connection => connection,
:owner => owner
:bucket => bucket,
:connection => connection,
:owner => owner
}.merge!(object))
end
objects
@ -48,6 +48,34 @@ module Fog
object
end
def get
data = connection.get_object(bucket.name, key, options)
object_data = { :body => data.body}
for key, value in data.headers
if ['Content-Length', 'Content-Type', 'ETag', 'Last-Modified'].include?(key)
object_data[key] = value
end
end
Fog::AWS::S3::Object.new({
:bucket => bucket,
:connection => connection
}.merge!(object_data))
end
def head
data = connection.head_object(bucket.name, key, options)
object_data = {}
for key, value in data.headers
if ['Content-Length', 'Content-Type', 'ETag', 'Last-Modified'].include?(key)
object_data[key] = value
end
end
Fog::AWS::S3::Object.new({
:bucket => bucket,
:connection => connection
}.merge!(object_data))
end
def new(attributes = {})
Fog::AWS::S3::Object.new({
:bucket => bucket,