Module Paperclip::Upfile
In: lib/paperclip/upfile.rb

The Upfile module is a convenience module for adding uploaded-file-type methods to the File class. Useful for testing.

  user.avatar = File.new("test/test_avatar.jpg")

Methods

Public Instance methods

Infer the MIME-type of the file from the extension.

[Source]

    # File lib/paperclip/upfile.rb, line 8
 8:     def content_type
 9:       type = self.path.match(/\.(\w+)$/)[1] rescue "octet-stream"
10:       case type
11:       when "jpg", "png", "gif" then "image/#{type}"
12:       when "txt" then "text/plain"
13:       when "csv", "xml", "html", "htm", "css", "js" then "text/#{type}"
14:       else "x-application/#{type}"
15:       end
16:     end

Returns the file‘s normal name.

[Source]

    # File lib/paperclip/upfile.rb, line 19
19:     def original_filename
20:       File.basename(self.path)
21:     end

Returns the size of the file.

[Source]

    # File lib/paperclip/upfile.rb, line 24
24:     def size
25:       File.size(self)
26:     end

[Validate]