Class: Paperclip::Tempfile

Inherits:
Tempfile show all
Defined in:
lib/paperclip/processor.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

Methods inherited from Tempfile

#size

Instance Method Details

#make_tmpname(basename, n) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/paperclip/processor.rb', line 45

def make_tmpname(basename, n)
  case basename
  when Array
    prefix, suffix = *basename
  else
    prefix, suffix = basename, ''
  end

  t = Time.now.strftime("%y%m%d")
  path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}-#{n}#{suffix}"
end