public

  • Download Gist
_swfupload_form.html.erb
HTML+ERB
1 2 3 4 5 6
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]) %>'
}
});
application.rb
Ruby
1
config.middleware.insert_before ActionDispatch::Session::CookieStore, Rack::FlashSession
flash_session.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.