title: Rails 3 get raw post data and write it to tmp file
body: <p>I'm working on implementing <a href="http://valums.com/ajax-upload/" rel="noreferrer">Ajax-Upload</a> for uploading photos in my Rails 3 app. The documentation says:</p>
  
  <blockquote>
    <ol>
    <li><p>For IE6-8, Opera, older versions of other browsers you get the file as you
    normally do with regular form-base
    uploads.</p></li>
    <li><p>For browsers which upload file with progress bar, you will need to get the
    raw post data and write it to the
    file.</p></li>
    </ol>
  </blockquote>
  
  <p>So, how can I receive the raw post data in my controller and write it to a tmp file so my controller can then process it? (In my case the controller is doing some image manipulation and saving to S3.)</p>
  
  <p>Some additional info:</p>
  
  <p>As I'm configured right now the post is passing these parameters:</p>
  
  <pre><code>Parameters:
  {"authenticity_token"=&gt;"...", "qqfile"=&gt;"IMG_0064.jpg"}
  </code></pre>
  
  <p>... and the CREATE action looks like this:</p>
  
  <pre><code>def create
      @attachment = Attachment.new
      @attachment.user = current_user
      @attachment.file = params[:qqfile]
      if @attachment.save!
          respond_to do |format|
              format.js { render :text =&gt; '{"success":true}' }
          end
      end
  end
  </code></pre>
  
  <p>... but I get this error:</p>
  
  <pre><code>ActiveRecord::RecordInvalid (Validation failed: File file name must be set.):
    app/controllers/attachments_controller.rb:7:in `create'
  </code></pre>