Mercurial > zeropaste
comparison app/controllers/pastes_controller.rb @ 151:db5164ff73a9
Always fill in @paste.ip when creating new one.
| author | Edho Arief <edho@myconan.net> |
|---|---|
| date | Mon, 26 Nov 2012 21:53:12 +0700 |
| parents | 0f206bd4924f |
| children | 500c09718fd7 |
comparison
equal
deleted
inserted
replaced
| 150:88f957e0352b | 151:db5164ff73a9 |
|---|---|
| 34 # POST / | 34 # POST / |
| 35 # POST /pastes.json | 35 # POST /pastes.json |
| 36 # POST /pastes.txt | 36 # POST /pastes.txt |
| 37 def create | 37 def create |
| 38 @paste = Paste.new | 38 @paste = Paste.new |
| 39 @paste.ip = request.remote_ip | |
| 39 if params[:paste] | 40 if params[:paste] |
| 40 if params[:paste][:paste_gzip_base64] | 41 if params[:paste][:paste_gzip_base64] |
| 41 # 1. decode from base64 | 42 # 1. decode from base64 |
| 42 # 2. create StringIO from decoded string | 43 # 2. create StringIO from decoded string |
| 43 # 3. unzip and read the stream | 44 # 3. unzip and read the stream |
| 44 params[:paste][:paste] = Zlib::GzipReader.new(StringIO.new(Base64.decode64(params[:paste][:paste_gzip_base64]))).read | 45 params[:paste][:paste] = Zlib::GzipReader.new(StringIO.new(Base64.decode64(params[:paste][:paste_gzip_base64]))).read |
| 45 end | 46 end |
| 46 unless params[:paste][:paste].blank? | 47 unless params[:paste][:paste].blank? |
| 47 @paste.paste = params[:paste][:paste] | 48 @paste.paste = params[:paste][:paste] |
| 48 @paste.ip = request.remote_ip | |
| 49 end | 49 end |
| 50 end | 50 end |
| 51 | 51 |
| 52 begin | 52 begin |
| 53 respond_to do |format| | 53 respond_to do |format| |
