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")
Infer the MIME-type of the file from the extension.
# File lib/dm-paperclip/upfile.rb, line 8 def content_type type = (self.path.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase case type when %jpe?g" then "image/jpeg" when %tiff?" then "image/tiff" when %png", "gif", "bmp" then "image/#{type}" when "txt" then "text/plain" when %html?" then "text/html" when "csv", "xml", "css", "js" then "text/#{type}" else "application/x-#{type}" end end
Generated with the Darkfish Rdoc Generator 2.