cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject Re: upload widget
Date Tue, 18 Mar 2008 03:18:30 GMT
On 17.03.2008 10:26, Felix Knecht wrote:

>>    part.copyToFile("new.pdf") ;
> 
> I don't think that 'part' implements a the function 'copyToFile' (at 
> least I haven't found it).

It is, but not really in a useful way:

     public void copyToFile(String filename) throws IOException {
         InputStream is = getInputStream();
         OutputStream os = new FileOutputStream(filename);
         IOUtils.copy(is, os);
         is.close();
         os.close();
     }

So the file is created relative to the JVM's base directory which is for 
Tomcat the bin directory in CATALINA_HOME (when started via the batch 
files in that directory).

I'd rather recommend to use absolute filenames or copyToSource(Source) 
and resolve the path you want to write to beforehands.

Also the above is a rather buggy implementation, there is no guarantee 
the streams are closed.

Joerg

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


Mime
View raw message