Skip to content

Instantly share code, notes, and snippets.

@pivotal-creationmix
Created October 5, 2010 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pivotal-creationmix/610974 to your computer and use it in GitHub Desktop.
Save pivotal-creationmix/610974 to your computer and use it in GitHub Desktop.
var swfup = new SWFUpload({
post_params : {
authenticity_token : '<%= u form_authenticity_token %>'
session: '<%= u request.env['rack.request.cookie_hash'].try(:[], Rails.application.config.session_options[:key]) %>'
}
});
config.middleware.insert_before ActionDispatch::Session::CookieStore, Rack::FlashSession
require 'rack/utils'
module Rack
class FlashSession
def initialize(app, session_key = Rails.application.config.session_options[:key])
@app = app
@session_key = session_key
end
def call(env)
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
req = Rack::Request.new(env)
session_data = req.params['session']
if session_data.blank?
log("error, env = #{env.inspect}")
else
env['HTTP_COOKIE'] = [@session_key, session_data].join('=').freeze
env['rack.request.query_hash'].delete('session')
env['rack.request.form_hash'].delete('session')
end
end
@app.call(env)
end
def log(message)
RAILS_DEFAULT_LOGGER.info(message)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment