You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by Ernesto Pin <er...@adinet.com.uy> on 2006/09/04 21:29:05 UTC
Uploading ZIP files
Hi. I'm trying to upload zip files to slide with WebdavResource.
putMethod(String, InputStream). The files are being successfully
uploaded, but if you get them, they are empty, or they have errors
(such as "file unexpectedly terminated"). ¿Any help?. Below is my
code....
Ernesto
public String altaPaquete(String psNombre, FileInputStream poFile)
throws
TPaqueteNoSubidoException {
if(poFile != null){
String lsServerRoot = getServerRoot() + ":" + getServerPort()
+ "/";
HttpURL loURL = new HttpURL(getServerRoot()+ ":" +
getServerPort());
boolean lbExito = false;
try {
loURL.setUserInfo(getUserName(),getUserPassword());
WebdavResource 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 Invocation is like this.....
File coFile = new File("aZipFile.zip");
FileInputStream loStream = new FileInputStream(coFile);
String lsURL = loServer.altaPaquete(coFile.getName(), loStream);
I must use Stream version of the method because this is going to be
invoked remotely (web browser)
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org