Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 20895 invoked by uid 500); 4 Apr 2003 15:13:11 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 20877 invoked from network); 4 Apr 2003 15:13:09 -0000 Received: from unknown (HELO pulse.betaversion.org) (217.158.110.65) by daedalus.apache.org with SMTP; 4 Apr 2003 15:13:09 -0000 Received: (qmail 25560 invoked from network); 4 Apr 2003 15:13:09 -0000 Received: from unknown (HELO apache.org) (stefano@80.105.91.155) by pulse.betaversion.org with SMTP; 4 Apr 2003 15:13:09 -0000 Message-ID: <3E8DA12D.10409@apache.org> Date: Fri, 04 Apr 2003 17:13:49 +0200 From: Stefano Mazzocchi User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Apache Cocoon Subject: How to use the file uploading mechanism in cocoon Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Start with the following page
the hook the /upload URL to a flow function then write the flow function var role = Packages.org.mystuff.UploadManager.ROLE; function upload() { var uploader = cocoon.componentManager.getComponent(role); var part = cocoon.request.get("blah"); var success = uploader.handle(part.getInputStream()); if (success) { sendPage("success.html"); } else { sendPage("failure.html"); } } alternatively, you can write the following java code in your sitemap components import org.apache.cocoon.servlet.multipart.*; ... Request request = ObjectModelHelper.getRequest(obj); if (request instanceof MultipartHttpServletRequest) { Part part = (Part) request.get("blah"); if (part != null) { // do something with it } else { // parameter not found } } else { // upload is disabled } Hope this helps (and gets thru) -- Stefano.