title: Download an image and save it
body: <p>what's the best way to download an image and save it?</p>
  
  <p>My current code is:</p>
  
  <pre><code>temp_file = Tempfile.new "filename", "#{RAILS_ROOT}/tmp/"
  temp_file.puts open(path_to_picture, 'User-Agent' =&gt; 'Test').read 
  mimetype = `file -ib #{temp_file.path}`.gsub(/\n/,"")
  </code></pre>
  
  <p>But it seems, that the mimetyp isn't ok.</p>
  
  <p>Best regards</p>