cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Cocoon Wiki] Update of "FileUploadWithAction" by JohannesTextor
Date Sun, 10 Jul 2005 12:19:37 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change notification.

The following page has been changed by JohannesTextor:
http://wiki.apache.org/cocoon/FileUploadWithAction

The comment on the change is:
Added changes to make it work in cocoon >= 2.1

------------------------------------------------------------------------------
  === File Upload with processing in an Action ===
  
- The code below is tested with Cocoon 2.03
+ The code below is tested with Cocoon 2.03. Refer to the end of the page if you want to use
it
+ with Cocoon >= 2.1
  
  Here's some sample code to demonstrate how to upload a file and do the processing of this
in an Action.
  
@@ -59, +60 @@

  
  For concept and configuration information for file uploads see FileUploadsWithCocoon
  
+ == Making it work on Cocoon 2.1 == 
+ 
+ If you are using Cocoon >= 2.1, you'll have to change the following imports:
+ 
+ {{{
+ import org.apache.cocoon.components.request.multipart.FilePart;
+ import org.apache.cocoon.components.request.multipart.FilePartFile;
+ }}}
+ 
+ to: 
+ 
+ {{{
+ import org.apache.cocoon.servlet.multipart.Part;
+ import org.apache.cocoon.servlet.multipart.PartOnDisk;
+ }}}
+ 
+ Consequently, the following lines 
+ {{{ 
+ FilePart filePart = (FilePart) request.get("uploaded_file");
+ 
+ File file = ((FilePartFile)filePart).getFile();
+ }}}
+ 
+ should read
+ {{{ 
+ Part filePart = (Part) request.get("uploaded_file");
+ 
+ File file = ((PartOnDisk)filePart).getFile();
+ }}}
+ 
+ Warning, this won't work if the servlet container stores the uploaded file in memory ({{PartInMemory}})
instead of creating a temporary file ({{PartOnDisk}}). 
+ 
  '''Attachment:''' attachment:Database
  

Mime
View raw message