From: <jta...@xa...> - 2003-02-03 09:50:09
|
Hi, If you are using eXist inside Cocoon 2.0.4 or 2.1-CVS, you would find=20 problems when adding a document with xadmin.xsp. This is because of the=20 way in which Cocoon handles the uploaded documents. In previous=20 versions of Cocoon, the uploaded document was automatically saved to=20 file, and there is a FilePartFile object to handle it. Now, by default,=20 the uploaded document is saved in memory (Ben, that's why you don't=20 find it in your upload-dir), and there is a FilePartArray object to=20 handle it. In general, the FilePart object represents the uploaded=20 file. Depending on how you configure "autosave-upload" parameter in=20 $COCOON_HOME/WEB-INF/web.xml, cocoon returns a FilePartFile (the file=20 is written to disk; autosave-upload=3Dtrue) or a FilePartArray (the file=20 is in memory; autosave-upload=3Dfalse). So, if you want to solve the problems when adding a document with=20 xadmin.xsp, you can configure autosave-upload parameter to true in=20 $COCOON_HOME/WEB-INF/web.xml (FilePartFile, save in File) or add the=20 following code snippet to xadmin.xsp (FilePartArray, save in memory) } else if(action.equals("store")) { try { FilePart filePart =3D (FilePart)request.get("uploaded_file"); InputStream is =3D filePart.getInputStream(); =09=09 Random rnd =3D new Random(); int b =3D rnd.nextInt(); Integer i =3D new Integer(b); String path =3D "/tmp/exist" + i.toString() + ".xml"; FileOutputStream fos =3D new FileOutputStream(path); =20 while ( (b =3D is.read()) !=3D -1) fos.write(b); fos.flush(); =09 =09 File file =3D new File(path); Oskar |