cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lionel Crine <cr...@4dconcept.fr>
Subject RE: Upload Action
Date Mon, 26 May 2003 16:09:08 GMT
I see!

I didn't find the post in the mailing archive. How bad i am.

thanks.


At 18:03 26/05/2003 +0200, you wrote:
>Hi,
>
>I already had a similar question recently and I got the following answer
>from one of the list members:
>
>****************************************************************************
>********
>
>... you should find what you need here:
>http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithFlow
>
>Notice the new package is org.apache.cocoon.servlet.multipart - some
>of the class names have changed, but most of the concepts are the
>same.  The bottom section should give you what you need to fix the
>action for uploads - if not, write back.
>
>...
>
>HTH,
>Geoff Howard
>
>****************************************************************************
>********
>
>This helps, but I still did not get my action to work correctly, since I was
>busy with something else.  I was trying to do the following, but my action
>always returns null:
>
>import java.util.HashMap;
>import java.util.Map;
>
>import org.apache.avalon.framework.logger.AbstractLogEnabled;
>import org.apache.avalon.framework.parameters.Parameters;
>import org.apache.avalon.framework.thread.ThreadSafe;
>import org.apache.cocoon.acting.Action;
>import org.apache.cocoon.environment.ObjectModelHelper;
>import org.apache.cocoon.environment.Redirector;
>import org.apache.cocoon.environment.Request;
>import org.apache.cocoon.environment.SourceResolver;
>import org.apache.cocoon.servlet.multipart.MultipartHttpServletRequest;
>import org.apache.cocoon.servlet.multipart.Part;
>
>public class UploadTest
>   extends AbstractLogEnabled
>   implements Action, ThreadSafe
>{
>         public Map act(Redirector redirector, SourceResolver resolver,
>                                    Map objectModel, String source,
>Parameters par)
>                 throws Exception
>         {
>                 Request request = ObjectModelHelper.getRequest(objectModel);
>
>              if (request instanceof MultipartHttpServletRequest) {
>                         Part part = (Part) request.get("blah");
>                         if (part != null) {
>                           getLogger().debug("Uploaded file = " +
>part.getFileName()
>                               + "  " + part.getUploadName());
>                           Map map = new HashMap();
>                           map.put("filepath", part.getFileName());
>                           return map;
>                           // do something with it
>                         } else {
>                           // parameter not found
>                         }
>                   } else {
>                         // upload is disabled
>                 }
>
>                 getLogger().debug("\nDebugger is on!\n");
>
>                 return null;
>         }
>}
>
>If you get it to work, could you please let me know how?  Thanks and good
>luck!
>
>Irina.
>
>
>
>
>
> > -----Original Message-----
> > From: Lionel Crine [mailto:crine@4dconcept.fr]
> > Sent: Montag, 26. Mai 2003 17:56
> > To: cocoon-users@xml.apache.org
> > Subject: Upload Action
> >
> >
> > I'm using the upload Action from Wiki site but i encounter
> > some trouble :
> >
> >
> > In the class :
> > ...
> > public class UploadTest
> >    extends AbstractLogEnabled
> >    implements Action, ThreadSafe
> > {
> >      public Map act(Redirector redirector, SourceResolver resolver,
> >                     Map objectModel, String source, Parameters par)
> >          throws Exception
> >      {
> >          Request request = ObjectModelHelper.getRequest(objectModel);
> >          FilePart filePart = (FilePart) request.get("uploaded_file");
> >
> >          File file = ((FilePartFile)filePart).getFile(); --->
> > Here I have a
> > NullPointerException.
> >          getLogger().debug("Uploaded file = " +
> > file.getCanonicalPath());
> >          return null;
> >      }
> > }
> >
> > Why does i have a NullPointerException ?
> >
> > Lionel
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Mime
View raw message