5

hi i would like to know how I can create a temporary file image (png) in ruby, because tempfile only gets you a random file name but it doesn't have an extension file.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
amy
  • 51
  • 1
  • 4

1 Answers1

7

check the documentation!

  # Use the Array form to enforce an extension in the filename:
  file = Tempfile.new(['hello', '.jpg'])
  file.path  # => something like: "/tmp/foo2843-8392-92849382--0.jpg"
Dutow
  • 5,638
  • 1
  • 30
  • 40