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
30 31 32 33 34 35 36 |
# File 'lib/fog/external/models/storage/file.rb', line 30 def body attributes[:body] ||= if last_modified directory.files.get(identity).body else '' end end |
#body=(new_body) ⇒ Object
38 39 40 |
# File 'lib/fog/external/models/storage/file.rb', line 38 def body=(new_body) attributes[:body] = new_body end |
#content_type ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/fog/external/models/storage/file.rb', line 22 def content_type @content_type ||= begin unless (mime_types = ::MIME::Types.of(key)).empty? mime_types.first.content_type end end end |
#destroy ⇒ Object
42 43 44 45 46 47 |
# File 'lib/fog/external/models/storage/file.rb', line 42 def destroy requires :key, :directory connection.remote.destroy_file(full_key) true end |
#directory ⇒ Object
14 15 16 |
# File 'lib/fog/external/models/storage/file.rb', line 14 def directory @directory end |
#directory=(new_directory) ⇒ Object
18 19 20 |
# File 'lib/fog/external/models/storage/file.rb', line 18 def directory=(new_directory) @directory = new_directory end |
#public=(new_public) ⇒ Object
49 50 51 |
# File 'lib/fog/external/models/storage/file.rb', line 49 def public=(new_public) new_public end |
#public_url ⇒ Object
53 54 55 |
# File 'lib/fog/external/models/storage/file.rb', line 53 def public_url nil end |
#save ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fog/external/models/storage/file.rb', line 57 def save requires :body, :directory, :key body_string = body.respond_to?(:read) ? body.read : body if res = connection.remote.save_file(full_key, body_string) merge_attributes( :content_length => Fog::Storage.get_body_size(body), :last_modified => res ) true else false end end |