Class: Paperclip::Tempfile

Inherits:
Tempfile
  • Object
show all
Defined in:
lib/paperclip/thumbnail.rb

Overview

Due to how ImageMagick handles its image format conversion and how Tempfile handles its naming scheme, it is necessary to override how Tempfile makes its names so as to allow for file extensions. Idea taken from the comments on this blog post: marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions

Instance Method Summary collapse

Instance Method Details

#make_tmpname(basename, n) ⇒ Object

Replaces Tempfile’s make_tmpname with one that honors file extensions.



75
76
77
78
# File 'lib/paperclip/thumbnail.rb', line 75

def make_tmpname(basename, n)
  extension = File.extname(basename)
  sprintf("%s,%d,%d%s", File.basename(basename, extension), $$, n, extension)
end