def file=(tempfile)
      tempfile.rewind #This may not be super efficient, but it's the necessary fix for Rails 3.1
      self["#{attachment_file_prefix}_data"] = tempfile.read
      
      size = nil
      if tempfile.respond_to?(:size)
        size = tempfile.size
      elsif tempfile.respond_to?(:stat)
        size = tempfile.stat.size
      end
      self["#{attachment_file_prefix}_size"] = size unless size.nil?

      filename = nil
      if tempfile.respond_to?(:original_filename)
        filename = tempfile.original_filename        
      elsif tempfile.respond_to?(:path)
        filename = File.basename(tempfile.path)
      end
      self["#{attachment_file_prefix}_name"] = filename unless filename.nil?

      self["#{attachment_file_prefix}_type"] = tempfile.content_type if tempfile.respond_to?(:content_type)
    end
def file=(tempfile)
      tempfile.rewind #This may not be super efficient, but it's the necessary fix for Rails 3.1
      self["#{attachment_file_prefix}_data"] = tempfile.read
      
      size = nil
      if tempfile.respond_to?(:size)
        size = tempfile.size
      elsif tempfile.respond_to?(:stat)
        size = tempfile.stat.size
      end
      self["#{attachment_file_prefix}_size"] = size unless size.nil?

      filename = nil
      if tempfile.respond_to?(:original_filename)
        filename = tempfile.original_filename        
      elsif tempfile.respond_to?(:path)
        filename = File.basename(tempfile.path)
      end
      self["#{attachment_file_prefix}_name"] = filename unless filename.nil?

      self["#{attachment_file_prefix}_type"] = tempfile.content_type if tempfile.respond_to?(:content_type)
    end
Take in a UploadFile and copy it's properties to four fields,
 data, size, original filename.  An UploadFile wraps a Tempfile,
 but includes some extra data (like the original filename and
 content type).  We can't garuntee this file to be at the beginning,
 so we always rewind it.