title: Write StringIO to Tempfile
body: <p>I am trying in ruby to read image from <em>url</em> and than save it to <code>Tempfile</code> to be later processed.</p>
  
  <pre><code>require 'open-uri'
  
  url = 'http://upload.wikimedia.org/wikipedia/commons/8/89/Robie_House.jpg'
  file = Tempfile.new(['temp','.jpg'])
  stringIo = open(url)
  # this is part I am confused about how to save StringIO to temp file?
  file.write stringIo
  </code></pre>
  
  <p>This does not work that is resulting <code>temp.jpg</code> is not valid image. Not sure how to proceed with this. </p>
  
  <p>Thanks</p>