Class: Fog::AWS::S3::Object

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/s3/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#inspect, #update_attributes

Constructor Details

#initialize(attributes = {}) ⇒ Object

Returns a new instance of Object.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/aws/models/s3/object.rb', line 16

def initialize(attributes = {})
  remap_attributes(attributes, {
    'Content-Length'  => :content_length,
    'ETag'            => :etag,
    'Key'             => :key,
    'LastModified'    => :last_modified,
    'Last-Modified'   => :last_modified,
    'Size'            => :size,
    'StorageClass'    => :storage_class
  })
  super
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



7
8
9
# File 'lib/fog/aws/models/s3/object.rb', line 7

def body
  @body
end

#content_lengthObject

Returns the value of attribute content_length.



7
8
9
# File 'lib/fog/aws/models/s3/object.rb', line 7

def content_length
  @content_length
end

#etagObject

Returns the value of attribute etag.



7
8
9
# File 'lib/fog/aws/models/s3/object.rb', line 7

def etag
  @etag
end

#keyObject

Returns the value of attribute key.



7
8
9
# File 'lib/fog/aws/models/s3/object.rb', line 7

def key
  @key
end

#last_modifiedObject

Returns the value of attribute last_modified.



7
8
9
# File 'lib/fog/aws/models/s3/object.rb', line 7

def last_modified
  @last_modified
end

#ownerObject

Returns the value of attribute owner.



7
8
9
# File 'lib/fog/aws/models/s3/object.rb', line 7

def owner
  @owner
end

#sizeObject

Returns the value of attribute size.



7
8
9
# File 'lib/fog/aws/models/s3/object.rb', line 7

def size
  @size
end

#storage_classObject

Returns the value of attribute storage_class.



7
8
9
# File 'lib/fog/aws/models/s3/object.rb', line 7

def storage_class
  @storage_class
end

Instance Method Details

#copy(target_bucket_name, target_object_key) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/aws/models/s3/object.rb', line 37

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
  copy_data = {}
  for key, value in data
    if ['ETag', 'LastModified'].include?(key)
      copy_data[key] = value
    end
  end
  copy.update_attributes(copy_data)
  copy
end

#deleteObject



50
51
52
# File 'lib/fog/aws/models/s3/object.rb', line 50

def delete
  connection.delete_object(bucket, key)
end

#save(options = {}) ⇒ Object



62
63
64
65
# File 'lib/fog/aws/models/s3/object.rb', line 62

def save(options = {})
  data = connection.put_object(bucket.name, key, body, options)
  @etag = data.headers['ETag']
end