Hi guys,

I've hooked mongrel_upload_progress into our application, and it's working now, but I noticed what might be a small bug.

The size of the file as reported by Mongrel is slightly bigger than the actual file size (both on the source computer + when it's stored on the server).

This difference varies slightly each time, but seems to be in the neighborhood of 420 - 486 extra bytes. My guess is that when Mongrel calculates the file size to give to upload progress, it doesn't strip out the HTTP header.

Here's the code snippet for the upload progress gem where the issue seems to be. The content length is returning the wrong number.

class Upload < GemPlugin::Plugin "/handlers"
  include Mongrel::HttpHandlerPlugin

  ...

  def request_begins(params)
upload_notify(:add, params, params [Mongrel::Const::CONTENT_LENGTH].to_i)
  end

I use this file size to ensure the upload completed successfully, but I have a workaround. I'm doing Flash based upload, and I can get the file size from Flash and send it to the server before the upload starts. But the all-server-side approach seems cleaner and more portable.

Small bug aside... this is a really cool gem ... it's letting me upload a file from one client and show the progress of the upload to other clients as they wait for the file.

-Pete

------
Pete DeLaurentis
Lead Software Engineer
NextEngine, Inc.
[EMAIL PROTECTED]




_______________________________________________
Mongrel-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/mongrel-users

Reply via email to