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)


12
13
14
# File 'lib/carrierwave/uploader/proxy.rb', line 12

def blank?
  file.blank?
end

#content_typeObject

Read the content type of the file

Returns

String

content type of the file



82
83
84
# File 'lib/carrierwave/uploader/proxy.rb', line 82

def content_type
  file.respond_to?(:content_type) ? file.content_type : nil
end

#current_pathObject Also known as: path

Returns

String

the path where the file is currently located.



21
22
23
# File 'lib/carrierwave/uploader/proxy.rb', line 21

def current_path
  file.path if file.respond_to?(:path)
end

#identifierObject

Returns a string that uniquely identifies the last stored file

Returns

String

uniquely identifies a file



34
35
36
# File 'lib/carrierwave/uploader/proxy.rb', line 34

def identifier
  storage.identifier if storage.respond_to?(: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.



71
72
73
# File 'lib/carrierwave/uploader/proxy.rb', line 71

def length
  size
end

#readObject

Read the contents of the file

Returns

String

contents of the file



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

def read
  file.read if file.respond_to?(:read)
end

#sizeObject

Fetches the size of the currently stored/cached file

Returns

Integer

size of the file



56
57
58
# File 'lib/carrierwave/uploader/proxy.rb', line 56

def size
  file.respond_to?(:size) ? file.size : 0
end