public class SftpClient extends Object
SftpClient
Wrapper around jsch sftp library. Provides access to basic
sftp commands.Modifier and Type | Class and Description |
---|---|
static class |
SftpClient.WriteMode |
Modifier and Type | Field and Description |
---|---|
static String |
CHANNEL_SFTP |
static String |
PREFERRED_AUTHENTICATION_METHODS |
static String |
STRICT_HOST_KEY_CHECKING |
Constructor and Description |
---|
SftpClient(String host) |
SftpClient(String host,
SftpNotifier notifier) |
Modifier and Type | Method and Description |
---|---|
void |
changeWorkingDirectory(String wd) |
void |
chmod(String path,
int permissions) |
protected void |
configureHostChecking(Properties hash) |
void |
createSftpDirIfNotExists(ImmutableEndpoint endpoint,
String newDir)
Creates the directory if it not already exists.
|
void |
deleteDirectory(String path) |
void |
deleteFile(String fileName) |
void |
disconnect() |
String |
duplicateHandling(String destDir,
String filename,
String duplicateHandling) |
String |
getAbsolutePath(String path)
Converts a relative path to an absolute path according to
http://tools.ietf.org/html/draft-ietf-secsh-scp-sftp-ssh-uri-04.
|
com.jcraft.jsch.ChannelSftp |
getChannelSftp() |
String |
getHost() |
File |
getKnownHostsFile() |
long |
getLastModifiedTime(String filename) |
long |
getSize(String filename) |
boolean |
isConnected() |
String[] |
listDirectories() |
String[] |
listDirectories(String path) |
String[] |
listFiles() |
String[] |
listFiles(String path) |
void |
login(String user,
String password) |
void |
login(String user,
String identityFile,
String passphrase) |
void |
mkdir(String directoryName)
Creates a directory
|
void |
recursivelyDeleteDirectory(String dir) |
void |
rename(String filename,
String dest) |
InputStream |
retrieveFile(String fileName) |
void |
setConnectionTimeoutMillis(int connectionTimeoutMillis) |
void |
setKnownHostsFile(File knownHostsFile) |
void |
setNotifier(SftpNotifier notifier) |
void |
setPort(int port) |
void |
setPreferredAuthenticationMethods(String preferredAuthenticationMethods) |
void |
storeFile(String fileName,
InputStream stream) |
void |
storeFile(String fileName,
InputStream stream,
SftpClient.WriteMode mode) |
void |
storeFile(String fileName,
MuleEvent event,
OutputHandler outputHandler) |
void |
storeFile(String fileName,
MuleEvent event,
OutputHandler outputHandler,
SftpClient.WriteMode mode) |
void |
storeFile(String fileNameLocal,
String fileNameRemote) |
void |
storeFile(String fileNameLocal,
String fileNameRemote,
SftpClient.WriteMode mode) |
public static final String CHANNEL_SFTP
public static final String STRICT_HOST_KEY_CHECKING
public static final String PREFERRED_AUTHENTICATION_METHODS
public SftpClient(String host)
public SftpClient(String host, SftpNotifier notifier)
public void changeWorkingDirectory(String wd) throws IOException
IOException
public String getAbsolutePath(String path)
path
- relative pathpublic void login(String user, String password) throws IOException
IOException
public void login(String user, String identityFile, String passphrase) throws IOException
IOException
protected void configureHostChecking(Properties hash) throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException
public File getKnownHostsFile()
public void setKnownHostsFile(File knownHostsFile)
public void setPort(int port)
public void setConnectionTimeoutMillis(int connectionTimeoutMillis)
public void rename(String filename, String dest) throws IOException
IOException
public void deleteFile(String fileName) throws IOException
IOException
public void disconnect()
public boolean isConnected()
public String[] listFiles() throws IOException
IOException
public String[] listFiles(String path) throws IOException
IOException
public String[] listDirectories() throws IOException
IOException
public String[] listDirectories(String path) throws IOException
IOException
public InputStream retrieveFile(String fileName) throws IOException
IOException
public void storeFile(String fileName, InputStream stream) throws IOException
IOException
public void storeFile(String fileName, InputStream stream, SftpClient.WriteMode mode) throws IOException
IOException
public void storeFile(String fileName, MuleEvent event, OutputHandler outputHandler) throws IOException
IOException
public void storeFile(String fileName, MuleEvent event, OutputHandler outputHandler, SftpClient.WriteMode mode) throws IOException
IOException
public void storeFile(String fileNameLocal, String fileNameRemote) throws IOException
IOException
public void storeFile(String fileNameLocal, String fileNameRemote, SftpClient.WriteMode mode) throws IOException
IOException
public long getSize(String filename) throws IOException
IOException
public long getLastModifiedTime(String filename) throws IOException
filename
- File nameIOException
- If an error occurspublic void mkdir(String directoryName) throws IOException
directoryName
- The directory nameIOException
- If an error occurspublic void deleteDirectory(String path) throws IOException
IOException
public com.jcraft.jsch.ChannelSftp getChannelSftp()
public void createSftpDirIfNotExists(ImmutableEndpoint endpoint, String newDir) throws IOException
endpoint
- newDir
- IOException
public String duplicateHandling(String destDir, String filename, String duplicateHandling) throws IOException
IOException
public void chmod(String path, int permissions) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public void setNotifier(SftpNotifier notifier)
public String getHost()
public void recursivelyDeleteDirectory(String dir) throws IOException
IOException
public void setPreferredAuthenticationMethods(String preferredAuthenticationMethods)
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.