Module: CarrierWave::Uploader::Proxy

Included in:
Base
Defined in:
lib/carrierwave/uploader/proxy.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns

Boolean

Whether the uploaded file is blank

Returns:

  • (Boolean)


10
11
12
# File 'lib/carrierwave/uploader/proxy.rb', line 10

def blank?
  file.blank?
end

#content_typeObject

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_pathObject 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

#identifierObject

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

#lengthObject

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

#sizeObject

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_identifierObject

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 the value of #cache_name is used



45
46
47
# File 'lib/carrierwave/uploader/proxy.rb', line 45

def temporary_identifier
  cache_name || @identifier
end