The code is complicated because, at some moment we have to check which content-type was coming and what to do.
I don't know if it was a good choice but it worked.


now, it's useless.

So I did what you said and here is a new example :

try {

Object oXml = this.request.get("moduleXml");
Part pod = (Part) oXml;
InputStream is = pod.getInputStream();

] catch ..........


The getAttribute method returns null.



Lionel


At 07:51 23/01/2004 +0100, you wrote:
Lionel Crine wrote:

Here is a sample code :

HttpServletRequest request = (HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
contentType = request.getContentType();
if (contentType == null) {
contentType = parameters.getParameter("defaultContentType", null);
}
if (contentType == null) {
throw new Exception("ERROR");
} else if (contentType.startsWith("application/x-www-form-urlencoded") || contentType.startsWith("multipart/form-data")) {
String parameter = parameters.getParameter(FORM_NAME, null);
if (parameter == null) {
throw new Exception("ERROR");
}
String sXml = request.getParameter(parameter);
inputSource = new InputSource(new FileInputStream(sXml));


} else if (contentType.startsWith("text/plain") || contentType.startsWith("text/xml") || contentType.startsWith("application/xml")) {

len = request.getContentLength();
if (len > 0) {
PostInputStream anStream = new PostInputStream(request.getInputStream(), len);
inputSource = new InputSource(anStream);
} else {
throw new SyspeoException("ERROR);
}
} else {
throw new SyspeoException("ERROR);
}


InputStream is = inputSource.getByteStream();


Hello Lionel,

sorry, but I don't know why you use this complicated code to realize uploads in cocoon. There is a solution which is very very easier!

1.) Set enable-uploads to true in web.xml.
2.) Get the uploaded file with request.getAttribute("filename_on_the_form");
3.) After that you will receive an object of type PartOnDisk for example. Use getFile() to receive the uploaded file.


Thats it. Isn't it easy?

More informations: http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithCocoon2.1

Regards
Stephan


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Lionel CRINE Ing�nieur Syst�mes documentaires Soci�t� : 4DConcept 22 rue Etienne de Jouy 78353 JOUY EN JOSAS Tel : 01.34.58.70.70 Fax : 01.39.58.70.70


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to