Class: Paperclip::UploadedFileAdapter
- Inherits:
-
Object
- Object
- Paperclip::UploadedFileAdapter
- Defined in:
- lib/paperclip/io_adapters/uploaded_file_adapter.rb
Instance Method Summary collapse
- #content_type ⇒ Object
- #eof? ⇒ Boolean
- #fingerprint ⇒ Object
-
#initialize(target) ⇒ UploadedFileAdapter
constructor
A new instance of UploadedFileAdapter.
- #nil? ⇒ Boolean
- #original_filename ⇒ Object
- #path ⇒ Object
- #read(length = nil, buffer = nil) ⇒ Object
-
#rewind ⇒ Object
We don’t use this directly, but aws/sdk does.
- #size ⇒ Object
Constructor Details
#initialize(target) ⇒ UploadedFileAdapter
Returns a new instance of UploadedFileAdapter.
3 4 5 6 7 8 9 10 11 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 3 def initialize(target) @target = target if @target.respond_to?(:tempfile) @tempfile = copy_to_tempfile(@target.tempfile) else @tempfile = copy_to_tempfile(@target) end end |
Instance Method Details
#content_type ⇒ Object
17 18 19 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 17 def content_type @target.content_type end |
#eof? ⇒ Boolean
42 43 44 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 42 def eof? @tempfile.eof? end |
#fingerprint ⇒ Object
21 22 23 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 21 def fingerprint @fingerprint ||= Digest::MD5.file(path).to_s end |
#nil? ⇒ Boolean
29 30 31 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 29 def nil? false end |
#original_filename ⇒ Object
13 14 15 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 13 def original_filename @target.original_filename end |
#path ⇒ Object
46 47 48 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 46 def path @tempfile.path end |
#read(length = nil, buffer = nil) ⇒ Object
33 34 35 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 33 def read(length = nil, buffer = nil) @tempfile.read(length, buffer) end |
#rewind ⇒ Object
We don’t use this directly, but aws/sdk does.
38 39 40 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 38 def rewind @tempfile.rewind end |
#size ⇒ Object
25 26 27 |
# File 'lib/paperclip/io_adapters/uploaded_file_adapter.rb', line 25 def size File.size(path) end |