Sha256: 9341fc6414cefadf154ed77613b909240a678f4b531cdc6208b8df7ea0cb7bc9
Contents?: true
Size: 911 Bytes
Versions: 1
Compression:
Stored size: 911 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").downcase Paperclip.content_type_for type 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 if defined? StringIO class StringIO attr_accessor :original_filename, :content_type def original_filename @original_filename ||= "stringio.txt" end def content_type @content_type ||= "text/plain" end end end class File #:nodoc: include Paperclip::Upfile end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
phildarnowsky-paperclip-2.2.10 | lib/paperclip/upfile.rb |