# HG changeset patch # User Edho Arief # Date 1368418773 -32400 # Node ID fb9909885d6360f3bd429a1870ba8643be5b4cef # Parent 9998d8b6c5240425b6628cb43da2fdedb79752d5 Also support plain gzip diff -r 9998d8b6c524 -r fb9909885d63 app/controllers/pastes_controller.rb --- a/app/controllers/pastes_controller.rb Mon May 13 13:19:13 2013 +0900 +++ b/app/controllers/pastes_controller.rb Mon May 13 13:19:33 2013 +0900 @@ -31,11 +31,15 @@ # POST /pastes.json # POST /pastes.txt def create - if params[:paste] && params[:paste][:paste_gzip_base64] - # 1. decode from base64 - # 2. create StringIO from decoded string - # 3. unzip and read the stream - params[:paste][:paste] = Zlib::GzipReader.new(StringIO.new(Base64.decode64(params[:paste].delete(:paste_gzip_base64)))).read + if params[:paste].is_a? Hash + if params[:paste][:paste_gzip_base64] + # 1. decode from base64 + # 2. create StringIO from decoded string + # 3. unzip and read the stream + params[:paste][:paste] = Zlib::GzipReader.new(StringIO.new(Base64.decode64(params[:paste].delete(:paste_gzip_base64)))).read + elsif params[:paste][:paste_gzip] + params[:paste][:paste] = Zlib::GzipReader.new(StringIO.new(params[:paste].delete(:paste_gzip))).read + end end @paste = Paste.new(paste_params.merge(ip: request.remote_ip))