Class: Fog::Storage::OpenStack::File
Instance Attribute Summary collapse
-
#delete_after ⇒ Integer
A number of seconds representing how long from now this object will be automatically deleted.
-
#delete_at ⇒ Integer
A Unix Epoch Timestamp, in integer form, representing the time when this object will be automatically deleted.
#project
Instance Method Summary
collapse
#create, #initialize, #update
Instance Attribute Details
#delete_after ⇒ Integer
A number of seconds representing how long from now this object will be automatically deleted.
27
|
# File 'lib/fog/openstack/models/storage/file.rb', line 27
attribute :delete_after, :aliases => ['X-Delete-After']
|
#delete_at ⇒ Integer
A Unix Epoch Timestamp, in integer form, representing the time when this object will be automatically deleted.
21
|
# File 'lib/fog/openstack/models/storage/file.rb', line 21
attribute :delete_at, :aliases => ['X-Delete-At']
|
Instance Method Details
#body ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/fog/openstack/models/storage/file.rb', line 29
def body
attributes[:body] ||= if last_modified
collection.get(identity).body
else
''
end
end
|
#body=(new_body) ⇒ Object
37
38
39
|
# File 'lib/fog/openstack/models/storage/file.rb', line 37
def body=(new_body)
attributes[:body] = new_body
end
|
#copy(target_directory_key, target_file_key, options = {}) ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'lib/fog/openstack/models/storage/file.rb', line 45
def copy(target_directory_key, target_file_key, options={})
requires :directory, :key
options['Content-Type'] ||= content_type if content_type
options['Access-Control-Allow-Origin'] ||= access_control_allow_origin if access_control_allow_origin
options['Origin'] ||= origin if origin
service.copy_object(directory.key, key, target_directory_key, target_file_key, options)
target_directory = service.directories.new(:key => target_directory_key)
target_directory.files.get(target_file_key)
end
|
#destroy ⇒ Object
55
56
57
58
59
|
# File 'lib/fog/openstack/models/storage/file.rb', line 55
def destroy
requires :directory, :key
service.delete_object(directory.key, key)
true
end
|
#directory ⇒ Object
41
42
43
|
# File 'lib/fog/openstack/models/storage/file.rb', line 41
def directory
@directory
end
|
61
62
63
|
# File 'lib/fog/openstack/models/storage/file.rb', line 61
def metadata
attributes[:metadata] ||=
end
|
#owner=(new_owner) ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/fog/openstack/models/storage/file.rb', line 65
def owner=(new_owner)
if new_owner
attributes[:owner] = {
:display_name => new_owner['DisplayName'],
:id => new_owner['ID']
}
end
end
|
#public=(new_public) ⇒ Object
74
75
76
|
# File 'lib/fog/openstack/models/storage/file.rb', line 74
def public=(new_public)
new_public
end
|
#public_url ⇒ Object
91
92
93
94
|
# File 'lib/fog/openstack/models/storage/file.rb', line 91
def public_url
requires :key
self.collection.get_url(self.key)
end
|
#save(options = {}) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/fog/openstack/models/storage/file.rb', line 96
def save(options = {})
requires :body, :directory, :key
options['Content-Type'] = content_type if content_type
options['Content-Disposition'] = content_disposition if content_disposition
options['Access-Control-Allow-Origin'] = access_control_allow_origin if access_control_allow_origin
options['Origin'] = origin if origin
options['X-Delete-At'] = delete_at if delete_at
options['X-Delete-After'] = delete_after if delete_after
options.merge!()
data = service.put_object(directory.key, key, body, options)
update_attributes_from(data)
refresh_metadata
self.content_length = Fog::Storage.get_body_size(body)
self.content_type ||= Fog::Storage.get_content_type(body)
true
end
|
#url(expires, options = {}) ⇒ String
Get a url for file.
required attributes: key
86
87
88
89
|
# File 'lib/fog/openstack/models/storage/file.rb', line 86
def url(expires, options = {})
requires :directory, :key
self.service.create_temp_url(directory.key, key, expires, "GET", options)
end
|