title: How can I specify a file name for my attachment with Paperclip?
body: <p>I have byte streams on the server that I'd like to attach to a model class with Paperclip, and I'd like to be able to specify the name that they're saved as on the filesystem.  Because I have a lot of these incoming files, I'd prefer to be able to create them as <code>Tempfiles</code> so that I don't have to worry about name collisions and deleting them manually and such.  This is what I'm doing:</p>
  
  <pre><code>desired_file_name = 'foo.txt'
  Tempfile.open([File.basename(desired_file_name), File.extname(desired_file_name)]) do |tf|
    tf.write(content_stream)
    tf.rewind
    model_obj.paperclip_attachment = tf
  end
  </code></pre>
  
  <p>That pretty much works.  The only problem is, my Paperclip attachment ends up with a tempfile name like foo.txt.201029392u-gyh-foh96y.txt.  So how can I tell Paperclip what to save my file as?  Calling <code>model_obj.paperclip_attachment_file_name = desired_file_name</code> doesn't work.  The DB field gets saved as that name, but on the filesystem I still have that tempfile name.</p>