diff options
Diffstat (limited to 'examples/rails_app-2.3.4/app/controllers/files_controller.rb')
-rw-r--r-- | examples/rails_app-2.3.4/app/controllers/files_controller.rb | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/examples/rails_app-2.3.4/app/controllers/files_controller.rb b/examples/rails_app-2.3.4/app/controllers/files_controller.rb index 004c13e..a0fdbb1 100644 --- a/examples/rails_app-2.3.4/app/controllers/files_controller.rb +++ b/examples/rails_app-2.3.4/app/controllers/files_controller.rb @@ -1,14 +1,15 @@ require 'digest/sha1' class FilesController < ApplicationController - # used by streaming upload progress + # used by jQuery streaming upload progress def new - if request.post? - size, hexdigest = _read_sha1_size - msg = "Successfully upload file (size: #{size}, sha1: #{hexdigest})" - flash[:notice] = msg - redirect_to "/files/new" - end + _sha1_flash_self + end + + # based on Ry Dahl's streaming AJAX pull: + # http://rubyforge.org/pipermail/mongrel-users/2007-July/003747.html + def pull + _sha1_flash_self end def index @@ -51,4 +52,13 @@ private [ file.size, digest.hexdigest ] end + def _sha1_flash_self + if request.post? + size, hexdigest = _read_sha1_size + msg = "Successfully upload file (size: #{size}, sha1: #{hexdigest})" + flash[:notice] = msg + redirect_to :action => params[:action] + end + end + end |