cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeroen ter Voorde <j.tervoo...@home.nl>
Subject Re: More control over iploading files
Date Sun, 14 Apr 2002 10:48:49 GMT
Hi,

You should be able to get the FilePart object representing the uploaded file
using request.get("upload_field"). If the file was stored into the upload dir 
(which is enabled by default) you can cast the FilePart to a FilePartFile 
from which you can get the java.io.File using getFile(). All other 
information on the file you can get from the the headers 
(FilePart.getHeaders()).

I've attached a sample action to move the file to another directory as
described above. 

To enable it add this to the top sitemap (above the xsp/* pipeline):

   <map:match pattern="xsp/upload">
    <map:act type="file-upload">
     <map:parameter name="upload-dir" value="myuploaddir" />
     <map:generate src="docs/samples/xsp/upload.xsp" type="serverpages" />
     <map:transform src="stylesheets/dynamic-page2html.xsl" />
     <map:serialize />
    </map:act>
   </map:match>

Note that the upload dir is created rin the webapps/cocoon dir instead of 
work/cocoon/cocoon-files.

I've tested this code against the current CVS (cocoon 2.1-dev branch). It will
probably not work with 2.0.2 since that release contained a bug 
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7510)

Greets,
	Jeroen

On Saturday 13 April 2002 02:41 am, you wrote:
> Hi all,
>
> I've been mucking around with some file upload stuff and noticed a change
> in behaviour since Joren's replacement for maybeupload was done back in
> Feb. Before the change it was possible to still get hold of the reference
> to the uploaded file from the request object in an action thus enabling you
> to rewrite the file anywhere e.g. into a db BLOB.  This is now not easily
> possible since the request does not contain the right stuff any more.  I
> note from the archives that when the code was submitted the suggestion was
> that control could be passed to an action to determine how and where to
> write the file but the final code is driven by the web.xml parameters.
>
> I would really like to have the ability to chose as often as each request
> where the uploaded file is to be put and will have a more detailed look at
> the code over the weekend to see what might need doing.  To me it seems
> there are a number of possible choices:
>
> 1. a small patch to the MultipartRequest stuff that leaves the required
> info in the request and then an action to do an upload to a place specified
> via a param
> 2. an alternative MultipartRequest handler
> 3. a complex action that works if SimpleRequestHandler is used and not
> Multipart - i.e. shift the work along (urgh?)
> 4. something else maybe
>
> Just interested on soliciting some thoughts on this whilst I tip tappity
> away!
>
> Cheers
>
> Jeremy
>
>
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com

Mime
View raw message