cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geert Josten" <geert.jos...@daidalos.nl>
Subject RE: upload:// pseudo protocol
Date Fri, 22 Sep 2006 06:51:29 GMT
Yes, the mechanism for uploading files is not that trivial, but to my
opinion quite flexible.

When you press submit in the HTML form, the file you try to upload is
attached to the HTML request. The built-in Cocoon (HTTP)Request object
is able to automatically recognize these attachments (provided you
activate enable-uploads in web.xml) and stores these in the Cocoon
working dir (Jetty temp folder or whatever is configured). Once done,
the request-parameter that identified the attachment is changed so that
it contains the path to this temp file.

Source factories are very flexible components that can be used anywhere
in Cocoon where access to sources is needed. The instruction in
cocoon.xconf you found defines an additional pseudo protocol, starting
with upload://. It takes the name of the request-param that contains the
reference to the uploaded file as parameter, reads the value of that
parameter, opens a Source object that points to the temp file, and
provides the input stream of the file to whichever component was
requesting for it.

I hopped through quite a lot of code a while ago and experimented a bit
to derive all this. Seems to me that you were on the right track.. :-)

About documentation: if there is no documentation in the header of the
relevant Java files, look for working examples or read the code. :-(

About previewing before publishing: I am not sure about the life-time of
these upload temp files, but I guess that all you need is to write a
FlowScript function that preserves the value of the upload request
parameter, calls a sendPageAndWait and depending on the returned request
parameters decide to publish the file or return to the upload screen
perhaps.

Kind regards,
Geert

> 
   
 
Drs. G.P.H. Josten
Consultant
 
 

Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665  JZ  Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
www.daidalos.nl
KvK 27164984


De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen,
verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.
 

> Van: Steven D. Majewski [mailto:sdm7g@virginia.edu] 
> Verzonden: donderdag 21 september 2006 23:58
> Aan: users@cocoon.apache.org
> Onderwerp: Re: upload:// pseudo protocol
> 
> 
> On Sep 21, 2006, at 4:20 PM, Steven D. Majewski wrote:
> 
> > Is the upload:// pseudo-protocol documented anywhere ?
> > ( I saw it in one of the samples, but could not find 
> anything in the 
> > docs. ) And if it isn't documented: where in the source 
> code should I 
> > look for info on how it's implemented ?
> >
> 
> I just managed to find this myself -- the indirection 
> implicit in cocoon's component model sometimes makes grepping 
> thru the sources a futile search. I see that all of the 
> protocol handlers ( upload as well as file, module, zip, 
> etc... )  are defined in cocoon.xconf :
> 
>      <component-instance
> class="org.apache.cocoon.components.source.impl.PartSourceFactory"  
> name="upload"/>
> 
> 
> Which gives me a start on figuring out how "upload://name" in 
> the sitemap manages to connect up with the MultipartParser.
> 
> 
> >
> > I'm still quite perplexed by all of the various ways of handling 
> > uploading in the cocoon samples, as well as the several methods 
> > documented on the wiki.
> >
> 
> But I'm still preplexed by much of the rest of it!
> 
> 
> -- Steve Majewski
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message