Module: CarrierWave::Uploader::Proxy
- Included in:
- Base
- Defined in:
- lib/carrierwave/uploader/proxy.rb
Instance Method Summary collapse
-
#blank? ⇒ Boolean
Returns.
-
#content_type ⇒ Object
Read the content type of the file.
-
#current_path ⇒ Object
(also: #path)
Returns.
-
#identifier ⇒ Object
Returns a string that uniquely identifies the retrieved or last stored file.
-
#length ⇒ Object
Return the size of the file when asked for its length.
-
#read(*args) ⇒ Object
Read the contents of the file.
-
#size ⇒ Object
Fetches the size of the currently stored/cached file.
Instance Method Details
#blank? ⇒ Boolean
Returns
- Boolean
-
Whether the uploaded file is blank
10 11 12 |
# File 'lib/carrierwave/uploader/proxy.rb', line 10 def blank? file.blank? end |
#content_type ⇒ Object
Read the content type of the file
Returns
- String
-
content type of the file
80 81 82 |
# File 'lib/carrierwave/uploader/proxy.rb', line 80 def content_type file.try(:content_type) end |
#current_path ⇒ Object Also known as: path
Returns
- String
-
the path where the file is currently located.
19 20 21 |
# File 'lib/carrierwave/uploader/proxy.rb', line 19 def current_path file.try(:path) end |
#identifier ⇒ Object
Returns a string that uniquely identifies the retrieved or last stored file
Returns
- String
-
uniquely identifies a file
32 33 34 |
# File 'lib/carrierwave/uploader/proxy.rb', line 32 def identifier @identifier || (file && storage.try(:identifier)) end |
#length ⇒ Object
Return the size of the file when asked for its length
Returns
- Integer
-
size of the file
Note
This was added because of the way Rails handles length/size validations in 3.0.6 and above.
69 70 71 |
# File 'lib/carrierwave/uploader/proxy.rb', line 69 def length size end |
#read(*args) ⇒ Object
Read the contents of the file
Returns
- String
-
contents of the file
43 44 45 |
# File 'lib/carrierwave/uploader/proxy.rb', line 43 def read(*args) file.try(:read, *args) end |
#size ⇒ Object
Fetches the size of the currently stored/cached file
Returns
- Integer
-
size of the file
54 55 56 |
# File 'lib/carrierwave/uploader/proxy.rb', line 54 def size file.try(:size) || 0 end |