Search in sources :

Example 1 with AFTPClient

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;
}
Also used : AFTPClient(lucee.runtime.net.ftp.AFTPClient) InputStream(java.io.InputStream) Resource(lucee.commons.io.res.Resource)

Example 2 with AFTPClient

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;
}
Also used : AFTPClient(lucee.runtime.net.ftp.AFTPClient)

Example 3 with AFTPClient

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;
}
Also used : AFTPClient(lucee.runtime.net.ftp.AFTPClient)

Example 4 with AFTPClient

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;
}
Also used : AFTPClient(lucee.runtime.net.ftp.AFTPClient) Struct(lucee.runtime.type.Struct)

Example 5 with AFTPClient

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;
}
Also used : AFTPClient(lucee.runtime.net.ftp.AFTPClient) Struct(lucee.runtime.type.Struct)

Aggregations

AFTPClient (lucee.runtime.net.ftp.AFTPClient)16 Struct (lucee.runtime.type.Struct)6 FTPFile (org.apache.commons.net.ftp.FTPFile)3 Resource (lucee.commons.io.res.Resource)2 ApplicationException (lucee.runtime.exp.ApplicationException)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 FTPConnection (lucee.runtime.net.ftp.FTPConnection)1