[prev in list] [next in list] [prev in thread] [next in thread]
List: slide-dev
Subject: Remote files PUT
From: Ernesto Pin <ernestopin () adinet ! com ! uy>
Date: 2006-09-05 14:01:28
Message-ID: 5291320.1157464888537.JavaMail.tomcat () fe-ps02
[Download RAW message or body]
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
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic