package com.zehon.sftp.samples;
/**
* This UploadFolderSample
class
* This sample demonstrates how to upload a folder (recursively) via SFTP, by creating your own BatchTransferProgress
* you can monitor the progress of the transferring.
* 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.htm for more information about our SFTP.
* @author Zehon Team (we're happy to serve you!) http://www.zehon.com/
*
*/
import com.zehon.BatchTransferProgressDefault;
import com.zehon.FileTransferStatus;
import com.zehon.exception.FileTransferException;
import com.zehon.sftp.SFTP;
public class UploadFolderSample {
/**
* Please refer to http://www.zehon.com/SFTP_samples.htm for its full source code
* @param args
*/
public static void main(String[] args) {
String host = "sftp.zehon.com";
String username = "sftp";
String password = "sftp";
String sendingFolder = "C:\\myfiles";
String destFolder = "/test";
try {
int status = SFTP.sendFolder(sendingFolder, destFolder, new BatchTransferProgressDefault(), host, username, password);
if(FileTransferStatus.SUCCESS == status){
System.out.println(sendingFolder + " got sftp-ed successfully to folder "+destFolder);
}
else if(FileTransferStatus.FAILURE == status){
System.out.println("Fail to ssftp to folder "+destFolder);
}
} catch (FileTransferException e) {
e.printStackTrace();
}
}
}