On Sun, Sep 14, 2003 at 10:01:05PM -0400, Geoff Howard wrote:
> Stephen Ramsay wrote:
> >On Sun, Sep 14, 2003 at 08:33:01AM -0400, Geoff Howard wrote:
> >
> >>Aha!  That wiki example has a problem I just noticed -- you shouldn't 
> >>return null here (I just corrected the wiki).  Use the corrected version 
> >>above - I'll explain below.

Well, Geoff, I just can't get it to work.  I'm no longer getting
404s, but it's still not uploading the file.

If you can stand it any longer, here's the rundown on what I've got.

First, the necessary switches have been turned on in web.xml:
upload-enabled is true, and the upload directory has been created (and enabled) with 
write permission for all.

The HTML file looks like this:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
  <title>Start Page</title>
</head>

<body bgcolor="white">
        <p>
        <form action="upload" method="POST" enctype="multipart/form-data">
                File: <input type="file" name="uploadfile" size="50"/><br/><br/>
                <input type="submit" name="action" value="Upload"/>
        </form>
  </p>
</body>
</html>

The action looks like this:

package edu.uga.english.cantor;

import java.io.File;
import java.io.FileInputStream;

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.Part;
import org.apache.cocoon.servlet.multipart.PartOnDisk;

public class SGUpload
  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);

                        Part filePart = (PartOnDisk) request.get("uploadfile");

                        if (filePart != null) {
                
                                getLogger().debug("Uploaded file = " + 
filePart.getFileName());

                        } else {

                                getLogger().debug("File not found");

                        }

                return java.util.Collections.EMPTY_MAP;

        }       

}

(it resides in
cocoon/WEB-INF/classes/edu/uga/cantor/english/SGUpload.java)

And, finally, the sitemap contains these two directives:

<map:actions>
        <map:action name="sg-upload" src="edu.uga.english.cantor.SGUpload"/>
</map:actions>

And:

<map:match pattern="upload">
        <map:act type="sg-upload">
                <map:read src="static/success.html" mime-type="text/html"/>
        </map:act>
</map:match>

I'm making some kind of progress; when I hit upload it fires off the
success page.  However, there's still no file, and more crucially,
no log.

I'm probably going to hack away at it for another session or so
(using some ideas from the code you sent), but it's really not
looking good . . .

You've already gone way above and beyond the bounds of hackerly
helpfulness, but if you get a chance to draw your eye over the
above, I'd be much obliged.

One last thing, though.  I am runnning tomcat (on Linux) using the
mod_jk module for Apache.  Would this make any difference?  I can't
think of why it would (mod_jk is a pretty straightforward pass-it-on
type thing, and it works fine for the rest of my cocoon stuff), but
I thought I'd mention it . . .

Steve

-- 
Stephen Ramsay
Assistant Professor
Department of English
University of Georgia
email: [EMAIL PROTECTED]
web: http://cantor.english.uga.edu/
PGP Public Key ID: 0xA38D7B11

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

Reply via email to