diff app/controllers/pastes_controller.rb @ 316:61f7f258a6fb

Move from-gzip paste parsing to model.
author edogawaconan <me@myconan.net>
date Sat, 05 Apr 2014 23:23:25 +0900
parents 200488650a86
children 612bc7c32324
line wrap: on
line diff
--- a/app/controllers/pastes_controller.rb	Sat Apr 05 23:20:32 2014 +0900
+++ b/app/controllers/pastes_controller.rb	Sat Apr 05 23:23:25 2014 +0900
@@ -29,16 +29,6 @@
   # POST /pastes.json
   # POST /pastes.txt
   def create
-    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))
 
     begin
@@ -77,6 +67,6 @@
 
   private
   def paste_params
-    params.require(:paste).permit(:paste, :is_private, :key)
+    params.require(:paste).permit(:paste, :paste_gzip, :paste_gzip_base64, :is_private, :key)
   end
 end