Remote files PUT

Ernesto Pin <[email protected]>
Newsgroups gmane.comp.jakarta.slide.devel
Message-ID <5291320.1157464888537.JavaMail.tomcat@fe-ps02>
I'm having troubles to upload files from a client's machine to Slide 
server. Locally (from the server), using WebdavResource.putMethod
(String, File). There was no problem, but, remotely, using 
WebdavResource.putMethod(String, InputStream) it didn`t work. In a 
particular case, uploaded zip files are empty, or have an "unexpected 
end of file reached". Any help?

Here is my code....

public String altaPaquete(String psNombre, InputStream poFile) throws 
        TPaqueteNoSubidoException {
    if(poFile != null){
        String lsServerRoot = getServerRoot() + ":" + getServerPort() 
+ "/";
        HttpURL loURL = new HttpURL(getServerRoot()+ ":" + 
getServerPort());
        boolean lbExito = false;
        WebdavResource loRemoteFile = null;
        try {
            loURL.setUserInfo(getUserName(),getUserPassword());
            loRemoteFile = new WebdavResource(loURL);
            lbExito = loRemoteFile.putMethod(getServerPath() + 
psNombre, poFile);
            loRemoteFile.close();
        } catch (MalformedURLException e) {
            throw new TPaqueteNoSubidoException("URL mal formada", e);
        } catch (HttpException e) {
            throw new TPaqueteNoSubidoException(e);
        } catch (IOException e) {
            throw new TPaqueteNoSubidoException(e);
        }
		    
        if(lbExito){
            return lsServerRoot + getServerPath() + psNombre;
        } else {
            throw new TPaqueteNoSubidoException("No se pudo guardar el 
archivo");
        }
    } else {
        throw new TPaqueteNoSubidoException("No se puede leer el 
archivo");
    }
}

... and the invocation

public void testAltaPaquete(){
    try{
        File fn = new File("c:\\Test.zip");
        FileInputStream loStream = new FileInputStream(fn);
        AccesoPaquetes loServer = new AccesoPaquetes(
                                                                
SERVER_ROOT,
                                                                
SERVER_PORT, 
                                                                
SERVER_PATH, 
                                                                
USER_NAME, 
                                                                
USER_PASS
                                                        );
        String lsURLEsperada = SERVER_ROOT + 
                                           ":8080/" + SERVER_PATH 
                                          + coFile.getName();
        String lsURL = loServer.altaPaquete(fn.getName(), loStream);
        assertTrue(lsURLEsperada.equals(lsURL));
    } catch (TPaqueteNoSubidoException ex){
        fail(ex.getMessage());
     } catch (FileNotFoundException ex) {
        fail("Archivo no encontrado");
     } 
}

This ends succesfully, with no fail.

Thanks a lot,
                  Ernesto
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.