Which "progress upload plugin" is good?

64 views
Skip to first unread message

Chamnap

unread,
Jul 11, 2007, 4:55:38 AM7/11/07
to Ruby on Rails: Talk
Hello,

I want to implement one upload application and want to show the
progress upload bar to the user. I am appreciate if you all could give
me some idea about which plugin you think it is good for you.

Thanks
Chamnap

Peter De Berdt

unread,
Jul 11, 2007, 7:37:34 AM7/11/07
to rubyonra...@googlegroups.com
I'm using SWFUpload with great success: http://swfupload.mammon.se/

Has upload progress (using client side technology, so no periodical hammering of your server) and has additional features such as upload queue (optional), file type filtering, multiple selection dialog, file size limiting (client side), …

Check out one of our public apps using it at http://demo.placid.be/albums/55;manage

If you need sessions for your uploads (user needs to be logged in to upload), this blog post will come in very handy:

Chamnap

unread,
Jul 11, 2007, 9:25:04 PM7/11/07
to Ruby on Rails: Talk
Hi Peter,

What do you think about Mongrel Upload Progress (http://
mongrel.rubyforge.org/docs/upload_progress.html)?

Thanks
Chamnap

Peter De Berdt

unread,
Jul 12, 2007, 3:46:01 AM7/12/07
to rubyonra...@googlegroups.com
On 12 Jul 2007, at 03:25, Chamnap wrote:

What do you think about Mongrel Upload Progress (http://

mongrel.rubyforge.org/docs/upload_progress.html)?


Although I'm sure it's a very good solution for other people on this list, my reasons not to use it are:
• Having to run another service (DRb) just for upload progress doesn't really appeal me. SWFUpload doesn't need another service to do what it does.
• The PeriodicalUpdater sends a status request to the server every three seconds, some of our apps are built around uploading files. Depending on the number of users, that would mean our server just gets hammered just for upload progress. SWFUpload gives constant feedback on the upload without one request to the server, it just measures the stream passed through the Flash file.
• I really needed client side filetype filtering and filesize limiting. It's of no use to us that multigigabyte file is first uploaded just to let the user know he couldn't do that. If it's uploaded, it's too late, as simple as that. Javascript doesn't allow local file access, but Flash does have some limited ability that comes in handy.
• SWFUpload is just so dead easy to implement: put the files in your /public/javascripts/ folder, include the javascript in the pages where you want "ajax uploads", and just HTML code and some javascript callbacks using prototype/scriptaculous.

As I said, some people really don't want to use a Flash-based solution out of principle or because their userbase doesn't have Flash installed, but our users for the most part are people that get all these funny little youtube movies from their coworkers and friends and watch them during their lunch break, i.e. Flash is installed everywhere :-) For us, SWFUpload is just the best solution to our problem.

Chamnap

unread,
Jul 12, 2007, 11:14:52 PM7/12/07
to Ruby on Rails: Talk
I agree with your idea.

Chamnap

Andrew Stewart

unread,
Aug 6, 2007, 6:03:37 AM8/6/07
to rubyonra...@googlegroups.com

On 11 Jul 2007, at 12:37, Peter De Berdt wrote:
> I'm using SWFUpload with great success: http://swfupload.mammon.se/
>
> Has upload progress (using client side technology, so no periodical
> hammering of your server) and has additional features such as
> upload queue (optional), file type filtering, multiple selection
> dialog, file size limiting (client side), ...

The site seems to be down at the moment. Does anybody happen to have
the SWFUpload library available publicly where I could grab it?

Thanks and regards,

Andy Stewart

Peter De Berdt

unread,
Aug 6, 2007, 8:06:53 AM8/6/07
to rubyonra...@googlegroups.com

On 06 Aug 2007, at 12:03, Andrew Stewart wrote:

The site seems to be down at the moment.  Does anybody happen to have  

the SWFUpload library available publicly where I could grab it?


Site's up for me

Andrew Stewart

unread,
Aug 7, 2007, 9:46:08 AM8/7/07
to rubyonra...@googlegroups.com

On 11 Jul 2007, at 12:37, Peter De Berdt wrote:
> I'm using SWFUpload with great success: http://swfupload.mammon.se/
>
> Has upload progress (using client side technology, so no periodical
> hammering of your server) and has additional features such as
> upload queue (optional), file type filtering, multiple selection
> dialog, file size limiting (client side), ...

>
> If you need sessions for your uploads (user needs to be logged in
> to upload), this blog post will come in very handy:
> http://blog.inquirylabs.com/2006/12/09/getting-the-_session_id-from-
> swfupload/
>

I'm trying to use SWFUpload but keep getting 302s returned when I
upload a file.

I am picking up the session correctly as per the blog post mentioned
above. I am able to read and store the files on the server side.

But instead of heeding my redirect at the end of my action, SWFUpload
somehow throws a 302s and stops the redirect.

Nothing untoward shows up in my Rails log. Each action just
completes with a 302.

I'd really like this to redirect as my action says.

Any help would be greatly appreciated.

Andrew Stewart

unread,
Aug 7, 2007, 10:11:24 AM8/7/07
to rubyonrails-talk

On 7 Aug 2007, at 14:46, Andrew Stewart wrote:
> I'm trying to use SWFUpload but keep getting 302s returned when I
> upload a file.
>
> I am picking up the session correctly as per the blog post
> mentioned above. I am able to read and store the files on the
> server side.
>
> But instead of heeding my redirect at the end of my action,
> SWFUpload somehow throws a 302s and stops the redirect.
>
> Nothing untoward shows up in my Rails log. Each action just
> completes with a 302.
>
> I'd really like this to redirect as my action says.

Just to clarify: I know that Rails redirects with a 302 status code
so that is working correctly. The question I'm asking is how to
prevent SWFUpload from treating this as an error.

Thanks in advance,

Andy Stewart


Peter De Berdt

unread,
Aug 7, 2007, 10:18:53 AM8/7/07
to rubyonra...@googlegroups.com
On 07 Aug 2007, at 15:46, Andrew Stewart wrote:

I'm trying to use SWFUpload but keep getting 302s returned when I  

upload a file.


I am picking up the session correctly as per the blog post mentioned  

above.  I am able to read and store the files on the server side.


This code needs to be in environment.rb

But instead of heeding my redirect at the end of my action, SWFUpload  

somehow throws a 302s and stops the redirect.


Nothing untoward shows up in my Rails log.  Each action just  

completes with a 302.


I'd really like this to redirect as my action says.


Any help would be greatly appreciated.


This is my code (still using an older version of swfupload, but the newer version should be similar):

Application controller
  before_filter :set_cookie_session

  def set_cookie_session
    @session_id = cookies[:_session_id]
  end


View
     <script type="text/javascript">

                mmSWFUpload.init({
                upload_backend : "<%= url_for(:action => "upload_file", :id => @myrecord.id, :_session_id => @session_id)-%>",
                target : "SWFUpload",
                allowed_filesize : "40000",
                allowed_filetypes : "*.jpg;*.png;*.zip",
                upload_start_callback : 'uploadStart',
                upload_progress_callback : 'uploadProgress',
                upload_complete_callback : 'uploadComplete',
                upload_queue_complete_callback : 'uploadQueueComplete'
                });
...

     uploadQueueComplete = function() {
                                ...
                                <%= remote_function(:url => {:action => :render_uploaded_files, :id => @myrecord.id}) -%>;
                                }

    </script>

Controller

  def upload_file
    # store the file, then
    render :nothing => true
  end

The key point to understand here is to render nothing or just a status code at the end of the method. Don't redirect. You need to handle the result by using the upload_complete_callback from SWFUpload (e.g. call a method through AJAX to render to file to the layout). The result code you send back at the end of the upload_file method let's the Flash movie SWFUpload uses know if the file was uploaded successfully, it doesn't interface with your HTML directly. Sending this result code back will cause the Flash movie to trigger the upload_queue_complete_callback, and then you're free to do whatever you want again.

Andrew Stewart

unread,
Aug 7, 2007, 11:37:58 AM8/7/07
to rubyonra...@googlegroups.com

On 7 Aug 2007, at 15:18, Peter De Berdt wrote:
> def upload_file
> # store the file, then
> render :nothing => true
> end
>
> The key point to understand here is to render nothing or just a
> status code at the end of the method. Don't redirect. You need to
> handle the result by using the upload_complete_callback from
> SWFUpload (e.g. call a method through AJAX to render to file to the
> layout). The result code you send back at the end of the
> upload_file method let's the Flash movie SWFUpload uses know if the
> file was uploaded successfully, it doesn't interface with your HTML
> directly. Sending this result code back will cause the Flash movie
> to trigger the upload_queue_complete_callback, and then you're free
> to do whatever you want again.

Thank you very much for that insight -- it's exactly what I needed.
Everything now works perfectly.

Thanks too for the code snippets.

Regards,
Andy Stewart

Reply all
Reply to author
Forward
0 new messages