# HG changeset patch # User Edho Arief # Date 1352175272 -25200 # Node ID 0f206bd4924fdf2d13d849e00216bc37e2aedfbb # Parent b245005ac9ac43e0b402564e3e39cc28f33fcc3d Allows posting gzipped text. diff -r b245005ac9ac -r 0f206bd4924f app/controllers/pastes_controller.rb --- a/app/controllers/pastes_controller.rb Tue Nov 06 00:09:13 2012 +0700 +++ b/app/controllers/pastes_controller.rb Tue Nov 06 11:14:32 2012 +0700 @@ -36,9 +36,17 @@ # POST /pastes.txt def create @paste = Paste.new - if params[:paste] and not params[:paste][:paste].blank? - @paste.paste = params[:paste][:paste] - @paste.ip = request.remote_ip + if params[:paste] + 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][:paste_gzip_base64]))).read + end + unless params[:paste][:paste].blank? + @paste.paste = params[:paste][:paste] + @paste.ip = request.remote_ip + end end begin