force encoding

This commit is contained in:
Espen Antonsen 2009-06-15 01:33:13 +02:00
parent 134305243a
commit f9baad9a3c
2 changed files with 2 additions and 1 deletions

View file

@ -10,6 +10,7 @@ class FlashSessionCookieMiddleware
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/ if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
params = ::Rack::Utils.parse_query(env['QUERY_STRING']) params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
env['HTTP_COOKIE'] = [ @session_key, params[@session_key] ].join('=').freeze unless params[@session_key].nil? env['HTTP_COOKIE'] = [ @session_key, params[@session_key] ].join('=').freeze unless params[@session_key].nil?
read_buffer.force_encoding("ascii-8bit") if RUBY_VERSION >= "1.9"
end end
@app.call(env) @app.call(env)
end end

View file

@ -82,7 +82,7 @@ class Photo < ActiveRecord::Base
data.content_type = MIME::Types.type_for(data.original_filename) data.content_type = MIME::Types.type_for(data.original_filename)
self.title = data.original_filename self.title = data.original_filename
self.path = self.album.path + "/" + data.original_filename self.path = self.album.path + "/" + data.original_filename
File.open(APP_CONFIG[:photos_path] + self.path, 'w:binary') { |f| f.write(data.read) } File.open(APP_CONFIG[:photos_path] + self.path, 'wb') { |f| f.write(data.read) }
RAILS_DEFAULT_LOGGER.info('swf_uploaded_data done') RAILS_DEFAULT_LOGGER.info('swf_uploaded_data done')
end end