Forum: Ruby on Rails Upload Progress Bar Problems

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2cf8b1b73b3e638843aec68dd39d9aee?d=identicon&s=25 Daniel Holmlund (agnathan)
on 2006-01-06 16:53
I'm writing an application where the user will be uploading many images
and user feedback is essential.

I've been trying to get the upload progress bar plug-in to work, but
thus far have not had any success.

I've downloaded Sean Treadway's application code  from his site
http://sean.treadway.info/demo/upload/  and I followed the steps in his
Upload Progress Checklist.

I've tried this on both my Gentoo and WinXP boxes using the Rails 1.0.


  def upload
      case @request.method
      when :post
          @message = 'File uploaded: ' +
params[:document][:file].size.to_s

          upload_progress.message = "Simulating some file processing
stage 1..."
          session.update

          # Dump information about uploads
          @session[:uploads].each {|k,v| logger.debug("Debug:
#{k}----->#{v.completed_percent}")}

          sleep(3)

          upload_progress.message = "Continuing processing stage 2..."
          session.update
          sleep(3)

          redirect_to :action => 'show'

          finish_upload_status "Hello '#{@message}'"
      end
  end

My problem is that no matter the file size by the time to debug
statement is reached the entire file has always been uploaded.  So the
progress bar jumps from 1 to 100 with no in between steps. I can step
through with a debugger and see this session being updated with file
size, bit rate, etc. information as the file is being uploaded, but no
luck with the bar.


Should I resign myself to putting up a pretty swirly animated graphic
and telling the user "it won't be long now" ?  has anybody had any
success with the getting the upload progress bar to work?  can anybody
provide any sample application code or suggest alternatives to using the
progress bar? thanks for any help...
45209aa526aa558a6551b22bf3035dff?d=identicon&s=25 prasad (Guest)
on 2006-04-11 08:21
Hi,

   I too have Rails 1.0 running under apache. But I am getting error
message for form_tag_with_upload_progress, it seems it's not identifying
this tag. The same happens in Rails 1.1. It would be very kind of you if
you can tell me something in this regard.

cheers..
Prasad

Daniel Holmlund wrote:
> I'm writing an application where the user will be uploading many images
> and user feedback is essential.
>
> I've been trying to get the upload progress bar plug-in to work, but
> thus far have not had any success.
>
> I've downloaded Sean Treadway's application code  from his site
> http://sean.treadway.info/demo/upload/  and I followed the steps in his
> Upload Progress Checklist.
>
> I've tried this on both my Gentoo and WinXP boxes using the Rails 1.0.
>
>
>   def upload
>       case @request.method
>       when :post
>           @message = 'File uploaded: ' +
> params[:document][:file].size.to_s
>
>           upload_progress.message = "Simulating some file processing
> stage 1..."
>           session.update
>
>           # Dump information about uploads
>           @session[:uploads].each {|k,v| logger.debug("Debug:
> #{k}----->#{v.completed_percent}")}
>
>           sleep(3)
>
>           upload_progress.message = "Continuing processing stage 2..."
>           session.update
>           sleep(3)
>
>           redirect_to :action => 'show'
>
>           finish_upload_status "Hello '#{@message}'"
>       end
>   end
>
> My problem is that no matter the file size by the time to debug
> statement is reached the entire file has always been uploaded.  So the
> progress bar jumps from 1 to 100 with no in between steps. I can step
> through with a debugger and see this session being updated with file
> size, bit rate, etc. information as the file is being uploaded, but no
> luck with the bar.
>
>
> Should I resign myself to putting up a pretty swirly animated graphic
> and telling the user "it won't be long now" ?  has anybody had any
> success with the getting the upload progress bar to work?  can anybody
> provide any sample application code or suggest alternatives to using the
> progress bar? thanks for any help...
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-04-11 08:29
Daniel,

I tried to get this working for a couple of days on Rails 1.0 and ended
up at the exact same place.

What I think that I observed was that the Ajax calls to do the updating
would not start until the file upload was complete, then the
intermediate status polling would begin.  So it would go from 0% to 100%
and then I would see the Ajax periodical updater calls happen.

Unfortunately, I finally gave up.  I did not get to debugging within the
upload code - I did my debugging on the client side, but my results are
consistent with yours.

Because this was my very first experience with Ajax and Prototype I
thought it best to get some other Ajax stuff working first before I came
back to it.  If you want to try and work through it together, perhaps we
could do that.

FWIW, you're not alone ;).

Thanks,
Wes

(Aside, As I said this was on Rails 1.0 - looks like all of these
components moved or disappeared for 1.1 - if you have any insight into
where they are in the 1.1 distribution, please advise...)

Daniel Holmlund wrote:
> I'm writing an application where the user will be uploading many images
> and user feedback is essential.
>
> I've been trying to get the upload progress bar plug-in to work, but
> thus far have not had any success.
>
> I've downloaded Sean Treadway's application code  from his site
> http://sean.treadway.info/demo/upload/  and I followed the steps in his
> Upload Progress Checklist.
>
> I've tried this on both my Gentoo and WinXP boxes using the Rails 1.0.
>
>
>   def upload
>       case @request.method
>       when :post
>           @message = 'File uploaded: ' +
> params[:document][:file].size.to_s
>
>           upload_progress.message = "Simulating some file processing
> stage 1..."
>           session.update
>
>           # Dump information about uploads
>           @session[:uploads].each {|k,v| logger.debug("Debug:
> #{k}----->#{v.completed_percent}")}
>
>           sleep(3)
>
>           upload_progress.message = "Continuing processing stage 2..."
>           session.update
>           sleep(3)
>
>           redirect_to :action => 'show'
>
>           finish_upload_status "Hello '#{@message}'"
>       end
>   end
>
> My problem is that no matter the file size by the time to debug
> statement is reached the entire file has always been uploaded.  So the
> progress bar jumps from 1 to 100 with no in between steps. I can step
> through with a debugger and see this session being updated with file
> size, bit rate, etc. information as the file is being uploaded, but no
> luck with the bar.
>
>
> Should I resign myself to putting up a pretty swirly animated graphic
> and telling the user "it won't be long now" ?  has anybody had any
> success with the getting the upload progress bar to work?  can anybody
> provide any sample application code or suggest alternatives to using the
> progress bar? thanks for any help...
This topic is locked and can not be replied to.