use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.
the class Ftp method actionGetFile.
/**
* gets a file from server and copy it local
* @return FTPCLient
* @throws PageException
* @throws IOException
*/
private AFTPClient actionGetFile() throws PageException, IOException {
required("remotefile", remotefile);
required("localfile", localfile);
AFTPClient client = getClient();
// new File(localfile);
Resource local = ResourceUtil.toResourceExistingParent(pageContext, localfile);
pageContext.getConfig().getSecurityManager().checkFileLocation(local);
if (failifexists && local.exists())
throw new ApplicationException("File [" + local + "] already exist, if you want to overwrite, set attribute failIfExists to false");
OutputStream fos = null;
client.setFileType(getType(local));
boolean success = false;
try {
fos = IOUtil.toBufferedOutputStream(local.getOutputStream());
success = client.retrieveFile(remotefile, fos);
} finally {
IOUtil.closeEL(fos);
if (!success)
local.delete();
}
writeCfftp(client);
return client;
}
Aggregations