title: AWS::S3::Errors::InvalidArgument with Paperclip PDF Upload
body: <p>I'm trying to upload a PDF to AWS S3 that is generated in a background process. The error I'm getting is a little cryptic and I was hoping someone had run into this or might be able to lead me in the right direction. I am using paperclip in other parts of the application, but these are taking form data where as this is creating a PDF and saving it to a local temp directory before uploading.</p>
  
  <p>Relevant gems:</p>
  
  <ul>
  <li>Rails 3.0.9</li>
  <li>paperclip 2.7.0</li>
  <li>aws-sdk 1.3.9</li>
  </ul>
  
  <p>code:</p>
  
  <pre><code>MyDownload &lt; ActiveRecord::Base
    has_attached_file :download,
      storage: :s3,
      default_style: :original,
      s3_permissions: 'authenticated_read',
      s3_credentials: "#{Rails.root}/config/s3.yml",
      bucket: S3_BUCKET,
      path: ":class/:attachment/:id/:style/:filename",
      s3_protocol: 'https'
  
    validates_attachment_content_type :download, content_type: [/application\/(x\-)?pdf/i]
    validates_attachment_presence :download
  
  end
  </code></pre>
  
  <p>During my background process I know the PDF is generated and can be viewed at tmp_path. Here is a little bit of the code I'm using:</p>
  
  <pre><code>PDFKit.new(report_content).to_file(tmp_path)
  obj = MyDownload.new(date: Date.today)
  obj.download = File.new(tmp_path)
  
  obj.valid? # returns true
  </code></pre>
  
  <p>But it fails when I do:</p>
  
  <pre><code>obj.save!
  
  (AWS::S3::Errors::InvalidArgument)
    (eval):3:in `put_object'
  </code></pre>