Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 2678 invoked from network); 23 Jan 2004 06:51:20 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 23 Jan 2004 06:51:20 -0000 Received: (qmail 91225 invoked by uid 500); 23 Jan 2004 06:50:54 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 91188 invoked by uid 500); 23 Jan 2004 06:50:54 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 91104 invoked from network); 23 Jan 2004 06:50:53 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.173) by daedalus.apache.org with SMTP; 23 Jan 2004 06:50:53 -0000 Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1Ajv9j-00053Q-00 for users@cocoon.apache.org; Fri, 23 Jan 2004 07:51:03 +0100 Received: from [80.128.82.176] (helo=gmx.net) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1Ajv9i-0001wx-00 for users@cocoon.apache.org; Fri, 23 Jan 2004 07:51:02 +0100 Message-ID: <4010C460.3070407@gmx.net> Date: Fri, 23 Jan 2004 07:51:12 +0100 From: Stephan Coboos User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 To: users@cocoon.apache.org Subject: Re: File upload/Multipart form References: <5.2.0.9.2.20040122193327.00b14388@10.0.0.162> In-Reply-To: <5.2.0.9.2.20040122193327.00b14388@10.0.0.162> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:431002173563032d2d00337e9d76f4cf X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org