use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.
the class Ftp method actionPutFile.
/**
* copy a local file to server
* @return FTPClient
* @throws IOException
* @throws PageException
*/
private AFTPClient actionPutFile() throws IOException, PageException {
required("remotefile", remotefile);
required("localfile", localfile);
AFTPClient client = getClient();
// new File(localfile);
Resource local = ResourceUtil.toResourceExisting(pageContext, localfile);
// if(failifexists && local.exists()) throw new ApplicationException("File ["+local+"] already exist, if you want to overwrite, set attribute failIfExists to false");
InputStream is = null;
try {
is = IOUtil.toBufferedInputStream(local.getInputStream());
client.setFileType(getType(local));
client.storeFile(remotefile, is);
} finally {
IOUtil.closeEL(is);
}
writeCfftp(client);
return client;
}
use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.
the class Ftp method actionRemoveDir.
/**
* removes a remote directory on server
* @return FTPCLient
* @throws IOException
* @throws PageException
*/
private AFTPClient actionRemoveDir() throws IOException, PageException {
required("directory", directory);
AFTPClient client = getClient();
if (recursive) {
removeRecursive(client, directory, FTPFile.DIRECTORY_TYPE);
} else
client.removeDirectory(directory);
writeCfftp(client);
return client;
}
use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.
the class Ftp method actionRename.
/**
* rename a file on the server
* @return FTPCLient
* @throws PageException
* @throws IOException
*/
private AFTPClient actionRename() throws PageException, IOException {
required("existing", existing);
required("new", _new);
AFTPClient client = getClient();
client.rename(existing, _new);
writeCfftp(client);
return client;
}
use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.
the class Ftp method actionGetCurrentDir.
/**
* get path from the working directory
* @return FTPCLient
* @throws IOException
* @throws PageException
*/
private AFTPClient actionGetCurrentDir() throws PageException, IOException {
AFTPClient client = getClient();
String pwd = client.printWorkingDirectory();
Struct cfftp = writeCfftp(client);
cfftp.setEL("returnValue", pwd);
return client;
}
use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.
the class Ftp method actionGetCurrentURL.
/**
* get url of the working directory
* @return FTPCLient
* @throws IOException
* @throws PageException
*/
private AFTPClient actionGetCurrentURL() throws PageException, IOException {
AFTPClient client = getClient();
String pwd = client.printWorkingDirectory();
Struct cfftp = writeCfftp(client);
cfftp.setEL("returnValue", client.getPrefix() + "://" + client.getRemoteAddress().getHostName() + pwd);
return client;
}
Aggregations