Class: Fog::Storage::External::File
- Inherits:
-
Model
- Object
- Model
- Fog::Storage::External::File
- Defined in:
- lib/fog/external/models/storage/file.rb
Instance Method Summary collapse
- #body ⇒ Object
- #body=(new_body) ⇒ Object
- #content_type ⇒ Object
- #destroy ⇒ Object
- #directory ⇒ Object
- #directory=(new_directory) ⇒ Object
- #public=(new_public) ⇒ Object
- #public_url ⇒ Object
- #save ⇒ Object
Instance Method Details
#body ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/fog/external/models/storage/file.rb', line 29 def body attributes[:body] ||= if last_modified directory.files.get(identity).body else '' end end |
#body=(new_body) ⇒ Object
37 38 39 |
# File 'lib/fog/external/models/storage/file.rb', line 37 def body=(new_body) attributes[:body] = new_body end |
#content_type ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/fog/external/models/storage/file.rb', line 21 def content_type @content_type ||= begin unless (mime_types = ::MIME::Types.of(key)).empty? mime_types.first.content_type end end end |
#destroy ⇒ Object
41 42 43 44 45 46 |
# File 'lib/fog/external/models/storage/file.rb', line 41 def destroy requires :key, :directory connection.remote.destroy_file(full_key) true end |
#directory ⇒ Object
13 14 15 |
# File 'lib/fog/external/models/storage/file.rb', line 13 def directory @directory end |
#directory=(new_directory) ⇒ Object
17 18 19 |
# File 'lib/fog/external/models/storage/file.rb', line 17 def directory=(new_directory) @directory = new_directory end |
#public=(new_public) ⇒ Object
48 49 50 |
# File 'lib/fog/external/models/storage/file.rb', line 48 def public=(new_public) new_public end |
#public_url ⇒ Object
52 53 54 |
# File 'lib/fog/external/models/storage/file.rb', line 52 def public_url nil end |
#save ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fog/external/models/storage/file.rb', line 56 def save requires :body, :directory, :key if res = connection.remote.save_file(full_key, body) merge_attributes( :content_length => Fog::Storage.get_body_size(body), :last_modified => res ) true else false end end |