Justin,
    You are correct! My problem is that Apache/mod_perl does not start to 
return anything unitl it has received the whole file.    I understand I need 
two two scripts.   One script is need to handle the <form> POST  and an 
additional script to handle AJAX POST that request the progress the file 
upload. The javascripts executes the AJAX POST script every second.     I want 
the second script to be mason.    How does the second script know where the 
files is being stored and obtain the progess information like the total size of 
the file and total number of bytes received.  I assumeing the first scripts 
must do some initialize for the second script.


I have a working CGI script... I want a mason script...
When I developed my CGI script I was able to can get an approximate total size 
of the file  from the CGI enviroment variable CONTENT_LENGTH  being passed 
before the file is transfer is complete.




From: Justin Wyllie [mailto:jus...@justinwylliephotography.com]
Sent: Wednesday, November 10, 2010 7:10 PM
To: Mason-users@lists.sourceforge.net
Subject: Re: [Mason] Mason File Upload Progress Bar

Hi MK

Looks like I got that the wrong way round. I should have tested before posting.

It looks like Apache/mod_perl does not start to return anything until it has 
received the whole file. I guess because the request is not complete until it 
has all arrived, which is Scott's problem. So your AJAX script is in the same 
page as the upload form. This is why of course you said the AJAX script is 
initialised by the onsubmit event.

So. You do need to know in advance where you will be storing the file right? I 
guess there are lots of ways of doing that - the page could create the filename 
and send it with the large file upload. Then it knows what to use in the AJAX. 
(Just so long as it is unique in some way). Or the page could have created one 
when it was displayed.

I still don't see where you are getting the total size from in your AJAX call?

Thanks

Justin








> MK,
>     Make sense...  So, create a page  like below. Unfortunately, I tried this 
> and it does not work because %init and %perl are only execute after the 
> complete file has been transfer to the server.  So, call to file size always 
> match total size.. This is even true for very large files ...
>
> <%args>
>  $filepath
>  $totalsize
> </%args>
>
> <%init>
>  #attempt to read the file size of filepath unfortunately...
>  # This is not execute until the complete file has been upload..
> </%init>
>
> <%perl>
>  #attempt to read the file size of filepath unfortunately...
>  # This is not execute until the complete file has been upload..
> </%perl>
> -----Original Message-----
> From: MK 
> [mailto:halfcountp...@intergate.com]<mailto:[mailto:halfcountp...@intergate.com]>
> Sent: Wednesday, November 10, 2010 4:20 PM
> To: Scott Dolan
> Cc: 
> Mason-users@lists.sourceforge.net<mailto:Mason-users@lists.sourceforge.net>
> Subject: Re: [Mason] Mason File Upload Progress Bar
>
> On Wed, 10 Nov 2010 20:39:31 +0000
> Scott Dolan <sdo...@v12groupinc.com<mailto:sdo...@v12groupinc.com>> wrote:
>> Thanks MK,
>>   But, I am looking for a pure mason and ajax and/or jquery solution.
>> I am currently have a solution similar to pastebin work using CGI and
>> ajax.
>
> I think you do not understand, sorry if I was not clear.  Suggestion #2 is 
> pure mason with ajax (which would be the best way to do it).
>
> Nb, jQuery is just a javascript library that (in part) implements "ajax" 
> methods (you can also write them yourself, but most people will recommend 
> against this because of hassles with maintenance, different browsers, etc). 
> "Ajax" itself is just conceptual:
>
> http://en.wikipedia.org/wiki/Ajax_(programming)
>
> It exploits the *client side* potential of javascript, which (short of flash, 
> et. al.) is necessary for communicating with the server and modifying page 
> content without replacing the entire page.
>
> Anyway, lemme try and explain that second suggestion again:
>
> 1) You write a mason script that accepts two parameters, a filepath and a 
> total size.  This page checks the current size of the file on the server, and 
> turns that into a percentage of the total size.  This is used to create the 
> html mark-up for the progress bar, which is what that .mhtml file creates (so 
> it's not a complete html page, it's just a partial "component").
>
> 2) Your file upload page fires a javascript rountine on submit that uses 
> setInterval (a standard javascript function) to poll the server, via some 
> AJAX method, every 1000 milliseconds.  The ajax call is to the mason page 
> from #1.  It receives fresh html from the mason component which you use to 
> update (replace) the progress bar, so that it reflects the size of the file 
> on the server.
>
> So, that's just a mason page and some javascript (probably making use of a 
> library such as jQuery).  Make sense?
>
> MK
>
> --
> "The angel of history[...]is turned toward the past." (Walter Benjamin)
>
> ------------------------------------------------------------------------------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> Mason-users mailing list
> Mason-users@lists.sourceforge.net<mailto:Mason-users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/mason-users
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to