You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Fabrice Morisseau <fa...@netyrinth.com> on 2002/02/12 17:49:59 UTC

Upload Service

Arrggg, i need help ;-)
I am trying to do an Upload file server with file send by a java program.
The upload action now extends VelocityAction instead of  SecureAction in 
order to avoid any authentification.

Problem is that doUpdate is never call.

Thanks
Fabrice


Client looks like this :

protected final static String BOUNDARY = 
"---------------------------7d159c1302d0y0";
...
        URL url = new 
URL("http://192.168.0.3:8080/NetyrinthWS/servlet/NetyrinthWS/action/Upload");
        HttpURLConnection connection = (HttpURLConnection) 
url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-type", 
"multipart/form-data; boundary=" + BOUNDARY);
        connection.setDoOutput(true);
        connection.setDoInput(true);
        OutputStream out = connection.getOutputStream();
        InputStream in = connection.getInputStream();
      
        // Write File    
        writeln(out,"--" + BOUNDARY);
        writeFileToURL(out,file);
        writeln(out,"--" + BOUNDARY);
        writeln(out,"Content-Disposition: form-data; 
name=\"eventSubmit_doUpload\"");
        writeln(out,"Upload");
        writeln(out,"--" + BOUNDARY+"--");
        out.flush();
        out.close();
...

and give the following generated content


-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="file"; 
filename="s1013531585912_1303096536.log"
Content-Type: application/octet-stream
Content of my file
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="eventSubmit_doUpload"
Upload
-----------------------------7d159c1302d0y0--


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>