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



80
81
82
# File 'lib/carrierwave/uploader/proxy.rb', line 80

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



69
70
71
# File 'lib/carrierwave/uploader/proxy.rb', line 69

def length
  size
end

#readObject

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
  file.try(:read)
end

#sizeObject

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