package com.zehon.ftps.samples;
/**
* This UploadFileSample
class
* This sample demonstrates how to upload a file via FTPs
* This sample uses a convenient method, for a Spring-able version of this refer to FTPsClient
* @see com.zehon.ftp.FTPsClient
* Please refer to http://www.zehon.com/features_ftps.htm for more information about our FTPs.
* @author Zehon Team (we're happy to serve you!) http://www.zehon.com/
*
*/
import com.zehon.FileTransferStatus;
import com.zehon.exception.FileTransferException;
import com.zehon.ftps.FTPs;
public class UploadFileSample {
/**
* Please refer to http://www.zehon.com/FTPs_samples.htm for its full source code
* @param args
*/
public static void main(String[] args) {
String host = "ftps.zehon.com";
String username = "ftps";
String password = "ftps";
String destFolder = "/test";
try {
String filePath = "C:\\myfiles\\files\\test.txt";
int status = FTPs.sendFile(filePath, destFolder, host, username, password);
if(FileTransferStatus.SUCCESS == status){
System.out.println(filePath + " got ftps-ed successfully to folder "+destFolder);
}
else if(FileTransferStatus.FAILURE == status){
System.out.println("Fail to ftps to folder "+destFolder);
}
} catch (FileTransferException e) {
e.printStackTrace();
}
}
}