Class: Fog::AWS::S3::Objects
Instance Method Summary
collapse
Methods inherited from Collection
aliases, attribute, attributes, #attributes, #initialize, #inspect, #merge_attributes
Instance Method Details
#all(options = {}) ⇒ Object
12
13
14
15
|
# File 'lib/fog/aws/models/s3/objects.rb', line 12
def all(options = {})
merge_attributes(options)
bucket.buckets.get(bucket.name, attributes).objects
end
|
17
18
19
|
# File 'lib/fog/aws/models/s3/objects.rb', line 17
def bucket
@bucket
end
|
#create(attributes = {}) ⇒ Object
21
22
23
24
25
|
# File 'lib/fog/aws/models/s3/objects.rb', line 21
def create(attributes = {})
object = new(attributes)
object.save
object
end
|
#get(key, options = {}) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/fog/aws/models/s3/objects.rb', line 27
def get(key, options = {})
data = connection.get_object(bucket.name, key, options)
object_data = {
:body => data.body,
:key => key
}
for key, value in data.
if ['Content-Length', 'Content-Type', 'ETag', 'Last-Modified'].include?(key)
object_data[key] = value
end
end
object = Fog::AWS::S3::Object.new({
:bucket => bucket,
:connection => connection,
:objects => self
}.merge!(object_data))
object
rescue Fog::Errors::NotFound
nil
end
|
#head(key, options = {}) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/fog/aws/models/s3/objects.rb', line 48
def head(key, options = {})
data = connection.head_object(bucket.name, key, options)
object_data = {
:key => key
}
for key, value in data.
if ['Content-Length', 'ETag', 'Last-Modified'].include?(key)
object_data[key] = value
end
end
object = Fog::AWS::S3::Object.new({
:bucket => bucket,
:connection => connection,
:objects => self
}.merge!(object_data))
object
rescue Fog::Errors::NotFound
nil
end
|
#new(attributes = {}) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/fog/aws/models/s3/objects.rb', line 68
def new(attributes = {})
Fog::AWS::S3::Object.new({
:bucket => bucket,
:connection => connection,
:objects => self
}.merge!(attributes))
end
|
76
77
78
|
# File 'lib/fog/aws/models/s3/objects.rb', line 76
def reload
all
end
|