Class: Fog::Storage::Softlayer::File
- Inherits:
-
Model
- Object
- Model
- Fog::Storage::Softlayer::File
- Defined in:
- lib/fog/softlayer/models/storage/file.rb
Instance Method Summary collapse
- #body ⇒ Object
- #body=(new_body) ⇒ Object
- #copy(target_directory_key, target_file_key, options = {}) ⇒ Object
- #destroy ⇒ Object
- #directory ⇒ Object
- #metadata ⇒ Object
- #owner=(new_owner) ⇒ Object
- #public=(new_public) ⇒ Object
- #public_url ⇒ Object
- #save(options = {}) ⇒ Object
-
#url(expires, options = {}) ⇒ String
Get a url for file.
Instance Method Details
permalink #body ⇒ Object
[View source]
24 25 26 27 28 29 30 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 24 def body attributes[:body] ||= if last_modified collection.get(identity).body else '' end end |
permalink #body=(new_body) ⇒ Object
[View source]
32 33 34 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 32 def body=(new_body) attributes[:body] = new_body end |
permalink #copy(target_directory_key, target_file_key, options = {}) ⇒ Object
[View source]
40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 40 def copy(target_directory_key, target_file_key, ={}) requires :directory, :key ['Content-Type'] ||= content_type if content_type ['Access-Control-Allow-Origin'] ||= access_control_allow_origin if access_control_allow_origin ['Origin'] ||= origin if origin service.copy_object(directory.key, key, target_directory_key, target_file_key, ) target_directory = service.directories.new(:key => target_directory_key) target_directory.files.get(target_file_key) end |
permalink #destroy ⇒ Object
[View source]
50 51 52 53 54 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 50 def destroy requires :directory, :key service.delete_object(directory.key, key) true end |
permalink #directory ⇒ Object
[View source]
36 37 38 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 36 def directory @directory end |
permalink #metadata ⇒ Object
[View source]
56 57 58 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 56 def @metadata ||= end |
permalink #owner=(new_owner) ⇒ Object
[View source]
60 61 62 63 64 65 66 67 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 60 def owner=(new_owner) if new_owner attributes[:owner] = { :display_name => new_owner['DisplayName'], :id => new_owner['ID'] } end end |
permalink #public=(new_public) ⇒ Object
[View source]
69 70 71 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 69 def public=(new_public) new_public end |
permalink #public_url ⇒ Object
[View source]
86 87 88 89 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 86 def public_url requires :key self.collection.get_url(self.key) end |
permalink #save(options = {}) ⇒ Object
[View source]
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 92 def save( = {}) requires :body, :directory, :key ['Content-Type'] = content_type if content_type ['Content-Disposition'] = content_disposition if content_disposition ['Access-Control-Allow-Origin'] = access_control_allow_origin if access_control_allow_origin ['Origin'] = origin if origin .merge!() data = service.put_object(directory.key, key, body, ) update_attributes_from(data) self.content_length = Fog::Storage.get_body_size(body) self.content_type ||= Fog::Storage.get_content_type(body) true end |
permalink #url(expires, options = {}) ⇒ String
Get a url for file.
required attributes: key
81 82 83 84 |
# File 'lib/fog/softlayer/models/storage/file.rb', line 81 def url(expires, = {}) requires :directory, :key self.service.create_temp_url(directory.key, key, expires, "GET", ) end |