Class: Swa::S3::Object

Inherits:
Resource show all
Defined in:
lib/swa/s3/object.rb

Instance Attribute Summary

Attributes inherited from Resource

#aws_resource

Instance Method Summary collapse

Methods inherited from Resource

#data, delegate, #initialize, list

Constructor Details

This class inherits a constructor from Swa::Resource

Instance Method Details

#deleteObject



40
41
42
# File 'lib/swa/s3/object.rb', line 40

def delete
  object.delete
end

#get_bodyObject



28
29
30
# File 'lib/swa/s3/object.rb', line 28

def get_body
  object.get.body
end

#keyObject



16
17
18
# File 'lib/swa/s3/object.rb', line 16

def key
  object.key
end

#put(io, options = {}) ⇒ Object



32
33
34
# File 'lib/swa/s3/object.rb', line 32

def put(io, options = {})
  object.put(options.merge(:body => io))
end

#summaryObject



8
9
10
11
12
13
14
# File 'lib/swa/s3/object.rb', line 8

def summary
  [
    object.last_modified.strftime("%Y-%m-%d %H:%M:%S"),
    rpad(object.size, 10),
    uri
  ].join("  ")
end

#to_sObject



24
25
26
# File 'lib/swa/s3/object.rb', line 24

def to_s
  uri
end

#upload(file_name) ⇒ Object



36
37
38
# File 'lib/swa/s3/object.rb', line 36

def upload(file_name)
  object.upload_file(file_name)
end

#uriObject



20
21
22
# File 'lib/swa/s3/object.rb', line 20

def uri
  "s3://#{object.bucket.name}/#{object.key}"
end