dan kuwachi
2007-Mar-14 18:45 UTC
is it possible to determine the file size before an actual upload?
I am doing a file upload where I want to constrain the maximum size to 1 mb, and I can check this data after the upload has completed. Is there a way to check this before the upload actually starts? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alex Wayne
2007-Mar-14 19:13 UTC
Re: is it possible to determine the file size before an actu
dan kuwachi wrote:> I am doing a file upload where I want to constrain the maximum size to > 1 mb, and I can check this data after the upload has completed. Is > there a way to check this before the upload actually starts?I don''t think you can do this. Rails will not even begin processing the action until the browser finishes sending the request. And the file upload is part of the request. I think you are at the mercy of HTTP here. But I could be completely wrong since I have heard of rails based file upload progress bars, so if anyone knows better feel free to shoot me down. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
eden li
2007-Mar-15 00:45 UTC
Re: is it possible to determine the file size before an actual upload?
If you''re using mongrel, you can write a handler to get information about the incoming request before it''s completely downloaded. You can then have your rails controllers connect to the handler via drb to get the content-length information the browser sends. Afaik, this is what mongrel''s upload progress handler does: http://mongrel.rubyforge.org/docs/upload_progress.html It''ll probably do what you need to do. If not, you can use it as inspiration for your own handler. On Mar 15, 2:45 am, "dan kuwachi" <dan.qu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am doing a file upload where I want to constrain the maximum size to > 1 mb, and I can check this data after the upload has completed. Is > there a way to check this before the upload actually starts?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---