title: How to integrate Paperclip and Mimetype-fu
body: <p>First, a little background, because there is a lot of interaction going on: I'm grabbing emails via Fetcher, and processing them using MMS2R to extract the attachments. These attachments are generally going to be PDF files or MS Word documents, so you'd expect that their <code>content-type</code> would be <code>application/pdf</code> and <code>application/msword</code> respectively, but unfortunately it appears that many mail programs do not do this.</p>
  
  <p>Instead, the attachments are <code>application/x-pdf</code> and <code>application/x-doc</code>. I need these to be set correctly so that scribd-fu will properly iPaper the documents. Now, mimetype-fu will manage to figure out the proper content-type, but for the life of me, I just can figure out how to properly set the content-type of the paperclip'd attachment.</p>
  
  <p>Here's a snippet of the code:</p>
  
  <pre><code>mms.process do |media_type, files|
    # go through each file
    files.each do |filename|
      # if it's a format we support, create a record
      if media_type =~ /pdf/  # just pdfs for now, to reduce confusion
        File.open(filename) do |tempfile| 
          # Somewhere in here I'd like to change filename.content_type
          # to the proper type using mimetype-fu
          # except doing tempfile.content_type = whatever doesn't seem to work.
  
          thing = Thing.new
          thing.document = tempfile
          thing.save!
        end
      end
    end
  end
  </code></pre>
  
  <p>Any help would be appreciated, because I've been beating my head against a wall trying all manner of things to try to get this working. I've tried these links already either without success or without grokking what needs doing:</p>
  
  <ul>
  <li><a href="http://gist.github.com/55009/" rel="nofollow noreferrer">http://gist.github.com/55009/</a></li>
  <li><a href="http://railsforum.com/viewtopic.php?id=27448" rel="nofollow noreferrer">http://railsforum.com/viewtopic.php?id=27448</a></li>
  <li><a href="http://github.com/dbackeus/paperclip/commit/a514bd03664fc6a764787f59c3169397336702b1" rel="nofollow noreferrer">http://github.com/dbackeus/paperclip/commit/a514bd03664fc6a764787f59c3169397336702b1</a></li>
  </ul>
  
  <p>Thanks greatly!</p>