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.
-
#temporary_identifier ⇒ Object
Returns a String which is to be used as a temporary value which gets assigned to the column.
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
93 94 95 |
# File 'lib/carrierwave/uploader/proxy.rb', line 93 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.
82 83 84 |
# File 'lib/carrierwave/uploader/proxy.rb', line 82 def length size end |
#read(*args) ⇒ Object
Read the contents of the file
Returns
- String
-
contents of the file
56 57 58 |
# File 'lib/carrierwave/uploader/proxy.rb', line 56 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
67 68 69 |
# File 'lib/carrierwave/uploader/proxy.rb', line 67 def size file.try(:size) || 0 end |
#temporary_identifier ⇒ Object
Returns a String which is to be used as a temporary value which gets assigned to the column. The purpose is to mark the column that it will be updated. Finally before the save it will be overwritten by the #identifier value, which is usually #filename.
Returns
- String
-
a temporary_identifier, by default @original_filename is used
45 46 47 |
# File 'lib/carrierwave/uploader/proxy.rb', line 45 def temporary_identifier @original_filename || @identifier end |