406 Not Acceptable with swfupload

---------flash_session_cookie_middleware.rb
require ‘rack/utils’

class FlashSessionCookieMiddleware
def initialize(app, session_key = ‘_session_id’)
@app = app
@session_key = session_key
end

def call(env)
if env[‘HTTP_USER_AGENT’] =~ /^(Adobe|Shockwave) Flash/
req = Rack::Request.new(env)
params = ::Rack::Utils.parse_query(env[‘QUERY_STRING’])
env[‘HTTP_COOKIE’] = [ @session_key, params[@session_key]
].join(’=’).freeze unless params[@session_key].nil?
end
@app.call(env)
end
end

------ controller
def create
@asset = Asset.new(params[:asset])

respond_to do |format|
  if params[:Filedata]
    @asset = Asset.new :swf_uploaded_data => params[:Filedata]
    @asset.user = current_user
    @asset.save!

    format.html { render :text => @asset.image.url(:thumb) }
    format.xml  { render :nothing => true }

  else
    if @asset.save
      flash[:notice] = 'Created'
      format.html { redirect_to(@asset) }
      format.xml  { render :xml => @asset, :status => :created,

:location => @asset }
else
format.html { render :action => “new” }
format.xml { render :xml => @asset.errors, :status =>
:unprocessable_entity }
end
end
end
end

-------- new.html.erb

New

<% form_for(@asset) do |f| %>
  <fieldset>
    <div id="divStatus">0 Files Uploaded</div>
      <div>
        <span id="spanButtonPlaceHolder"></span>
      </div>
  </fieldset>
<% end %>

<%= link_to 'back', assets_path %>

Once the upload completes, the browser throws a 406 error, despite the
image uploading.

I added env[‘HTTP_ACCEPT’] = ‘/’ into my middleware. It seems
to work correctly now.