Sha256: a525ee272c13c2e2777e7421430e90e7146ec71ea3925a92702ef30d6992e852
Contents?: true
Size: 809 Bytes
Versions: 2
Compression:
Stored size: 809 Bytes
Contents
module Paperclip # 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") module Upfile # Infer the MIME-type of the file from the extension. def content_type type = self.path.match(/\.(\w+)$/)[1] rescue "octet-stream" case type when "jpg", "png", "gif" then "image/#{type}" when "txt", "csv", "xml", "html", "htm", "css", "js" then "text/#{type}" else "x-application/#{type}" end end # Returns the file's normal name. def original_filename File.basename(self.path) end # Returns the size of the file. def size File.size(self) end end end class File #:nodoc: include Paperclip::Upfile end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
avatar-0.0.5 | test/lib/paperclip/lib/paperclip/upfile.rb |
paperclip-2.1.0 | lib/paperclip/upfile.rb |