Top Inners Fields Methods
org.apache.sshd.sftp.client

public Interface SftpClient

extends SubsystemClient
Known Direct Subinterfaces
org.apache.sshd.sftp.client.FullAccessSftpClient
Imports
java.io.IOException, .InputStream, .OutputStream, java.nio.channels.Channel, .FileChannel, java.nio.charset.Charset, java.nio.file.Files, .OpenOption, .Path, .StandardOpenOption, java.nio.file.attribute.AclEntry, .FileTime, java.util.Arrays, .Collection, .Collections, .Comparator, .EnumSet, .LinkedList, .List, .Map, .NavigableMap, .Objects, .Set, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.AtomicReference, org.apache.sshd.client.subsystem.SubsystemClient, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.apache.sshd.common.util.buffer.BufferUtils, org.apache.sshd.common.util.functors.UnaryEquator, org.apache.sshd.sftp.SftpModuleProperties, org.apache.sshd.sftp.client.extensions.BuiltinSftpClientExtensions, .SftpClientExtension, .SftpClientExtensionFactory, org.apache.sshd.sftp.common.SftpConstants, .SftpHelper

Author
Apache MINA Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static class
public abstract static class
public static enum
public static class
public static class
public static enum

Field Summary

Modifier and TypeField and Description
public static final Set<SftpClient.OpenMode>
DEFAULT_CHANNEL_MODES

Default modes for opening a channel if no specific modes specified

public static final SftpClient.DirEntry[]
public static final int
public static final int
public static final int
public static final int

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The effective "normalized" remote path
canonicalPath
(String
The requested path - may be relative, and/or contain dots - e.g., ".", "..", "./foo", "../bar"
path
)

The effective "normalized" remote path

public void
close(SftpClient.Handle
The Handle to close
handle
)

Close the handle obtained from one of the open methods

public default <
The generic extension type
E extends SftpClientExtension
>
E

Returns:

The extension instance - Note: it is up to the caller to invoke SftpClientExtension#isSupported() - null if this extension type is not implemented by the client
getExtension
(Class<? extends E>
The extension type
extensionType
)

public default SftpClientExtension

Returns:

The extension instance - Note: it is up to the caller to invoke SftpClientExtension#isSupported() - null if this extension type is not implemented by the client
getExtension
(String
The extension name
extensionName
)

public SftpClientExtension

Returns:

The extension instance - Note: it is up to the caller to invoke SftpClientExtension#isSupported() - null if this extension type is not implemented by the client
getExtension
(SftpClientExtensionFactory
The SftpClientExtensionFactory instance to use - ignored if null
factory
)

public default String
public Charset

Returns:

The (never null) Charset used to decode referenced files/folders names
getNameDecodingCharset
()

public NavigableMap<String, byte[]>

Returns:

An (unmodifiable) NavigableMap of the reported server extensions. where key=extension name (case insensitive)
getServerExtensions
()

public int

Returns:

The negotiated SFTP protocol version
getVersion
()

public boolean
public Iterable<SftpClient.DirEntry>

Returns:

An Iterable that can be used to iterate over all the directory entries (like readDir(String))

Note

the iterable instance is not re-usable - i.e., files can be iterated only once

listDir
(SftpClient.Handle
A directory Handle
handle
)

public void
lock(SftpClient.Handle handle, long offset, long length, int mask)

public SftpClient.Attributes

Returns:

The associated Attributes
lstat
(String
The remote path
path
)

Retrieve remote path meta-data - do not follow symbolic links

public void
mkdir(String
Remote directory path
path
)

Create remote directory

public default SftpClient.CloseableHandle

Returns:

The file's CloseableHandle
open
(String
The remote path
path
)

Opens a remote file for read

public default SftpClient.CloseableHandle

Returns:

The file's CloseableHandle
open
(String
The remote path
path
,
SftpClient.OpenMode...
The desired mode - if none specified then OpenMode#Read is assumed
options
)

Opens a remote file with the specified mode(s)

public SftpClient.CloseableHandle

Returns:

The file's CloseableHandle
open
(String
The remote path
path
,
Collection<SftpClient.OpenMode>
The desired mode - if none specified then OpenMode#Read is assumed
options
)

Opens a remote file with the specified mode(s)

public SftpClient.CloseableHandle

Returns:

The associated directory Handle
openDir
(String
Remote directory path
path
)

Obtain a handle for a directory

public default FileChannel
public FileChannel

Returns:

The open FileChannel - Note: do not close this owner client instance until the channel is no longer needed since it uses the client for providing the channel's functionality.
openRemoteFileChannel
(String
The remote path
path
,
Collection<SftpClient.OpenMode>
The access mode(s) - if null/empty then the DEFAULT_CHANNEL_MODES are used
modes
)

Opens an FileChannel on the specified remote path

public default FileChannel
public default FileChannel
public default void
put(Path localFile, String path)

public default void
put(InputStream stream, String path)

public default void
put(Path localFile, int bufferSize, String path)

public default void
put(InputStream stream, int bufferSize, String path)

public default void
put(Path localFile, String path, SftpClient.OpenMode... modes)

public default void
put(InputStream stream, String path, SftpClient.OpenMode... modes)

public default void
put(Path localFile, int bufferSize, String path, SftpClient.OpenMode... modes)

public default void
put(InputStream stream, int bufferSize, String path, SftpClient.OpenMode... modes)

public default void
put(Path localFile, String path, Collection<SftpClient.OpenMode> modes)

public default void
public default void
put(Path
Path of the local file to upload
localFile
,
int
SFTP packet size; i.e., amount of data to send in a single SFTP request. Most servers have a limit of 256kB. If zero, a default buffer size is chosen depending on the peer's channel packet size; so typically about 32kB.
bufferSize
,
String
The remote file path
path
,
Collection<SftpClient.OpenMode> modes)

Uploads a local file to a remote file.

public void
put(InputStream
InputStream to read from
stream
,
int
SFTP packet size; i.e., amount of data to send in a single SFTP request. Most servers have a limit of 256kB. If zero, a default buffer size is chosen depending on the peer's channel packet size; so typically about 32kB.
bufferSize
,
String
The remote file path
path
,
Collection<SftpClient.OpenMode> modes)

Write data from an InputStream to a remote file.

public default int

Returns:

Number of read bytes - -1 if EOF reached
read
(SftpClient.Handle
The file Handle to read from
handle
,
long
The file offset to read from
fileOffset
,
byte[]
The destination buffer
dst
)

Reads data from the open (file) handle

public default int

Returns:

Number of read bytes - -1 if EOF reached
read
(SftpClient.Handle
The file Handle to read from
handle
,
long
The file offset to read from
fileOffset
,
byte[]
The destination buffer
dst
,
AtomicReference<Boolean>
If not null then upon return holds a value indicating whether EOF was reached due to the read. If null indicator value then this indication is not available
eofSignalled
)

Reads data from the open (file) handle

public default int
read(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len)

public int

Returns:

Number of read bytes - -1 if EOF reached
read
(SftpClient.Handle
The file Handle to read from
handle
,
long
The file offset to read from
fileOffset
,
byte[]
The destination buffer
dst
,
int
Offset in destination buffer to place the read data
dstOffset
,
int
Available destination buffer size to read
len
,
AtomicReference<Boolean>
If not null then upon return holds a value indicating whether EOF was reached due to the read. If null indicator value then this indication is not available
eofSignalled
)

Reads data from the open (file) handle

public default InputStream
read(String path)

public default InputStream
read(String path, int bufferSize)

public default InputStream
read(String path, SftpClient.OpenMode... mode)

public default InputStream
read(String path, int bufferSize, SftpClient.OpenMode... mode)

public default InputStream
public InputStream

Returns:

An InputStream for reading the remote file data
read
(String
The remote file path
path
,
int
The internal read buffer size
bufferSize
,
Collection<SftpClient.OpenMode>
The remote file OpenModes
mode
)

Read a remote file's data via an input stream

public default List<SftpClient.DirEntry>

Returns:

A List of entries - null to indicate no more entries Note: the list may be incomplete since the client and server have some internal imposed limit on the number of entries they can process. Therefore several calls to this method may be required (until null). In order to iterate over all the entries use readDir(String)
readDir
(SftpClient.Handle
Directory Handle to read from
handle
)

public List<SftpClient.DirEntry>

Returns:

A List of entries - null to indicate no more entries
readDir
(SftpClient.Handle
Directory Handle to read from
handle
,
AtomicReference<Boolean>
An indicator that can be used to get information whether end of list has been reached - ignored if null. Upon return, set value indicates whether all entries have been exhausted - a null value means that this information cannot be provided and another call to readDir is necessary in order to verify that no more entries are pending
eolIndicator
)

public Iterable<SftpClient.DirEntry>

Returns:

An Iterable that can be used to iterate over all the directory entries (unlike readDir(Handle))
readDir
(String
The remote directory path
path
)

public default Collection<SftpClient.DirEntry>

Returns:

A Collection of all the entries in the remote directory
readEntries
(String
Remote directory path
path
)

Reads all entries available for a directory

public void
remove(String
The remote path to remove
path
)

public default void
rename(String oldPath, String newPath)

public default void
rename(String oldPath, String newPath, SftpClient.CopyMode... options)

public void
rename(String oldPath, String newPath, Collection<SftpClient.CopyMode> options)

public void
rmdir(String
Remote directory path
path
)

Remove remote directory

public void
public void
setStat(String
The remote path
path
,
SftpClient.Attributes
The Attributes to update
attributes
)

Update remote node meta-data

public void
setStat(SftpClient.Handle
The Handle obtained via one of the open calls
handle
,
SftpClient.Attributes
The Attributes to update
attributes
)

Update remote node meta-data

public default SftpClient

Returns:

The wrapper instance
singleSessionInstance
()

Creates an SftpClient instance that also closes the underlying client session when the client instance is closed.

public SftpClient.Attributes

Returns:

The associated Attributes
stat
(String
The remote path
path
)

Retrieve remote path meta-data - follow symbolic links if encountered

public SftpClient.Attributes

Returns:

The associated Attributes
stat
(SftpClient.Handle
The Handle obtained via one of the open calls
handle
)

Retrieve file/directory handle meta-data

public void
unlock(SftpClient.Handle handle, long offset, long length)

public default void
write(SftpClient.Handle handle, long fileOffset, byte[] src)

public void
write(SftpClient.Handle
The file Handle
handle
,
long
Zero-based offset to write in file
fileOffset
,
byte[]
Data buffer
src
,
int
Offset of valid data in buffer
srcOffset
,
int
Number of bytes to write
len
)

Write data to (open) file handle

public default OutputStream
write(String path)

public default OutputStream
write(String path, int bufferSize)

public default OutputStream
public default OutputStream
write(String path, int bufferSize, SftpClient.OpenMode... mode)

public default OutputStream
public OutputStream

Returns:

An OutputStream for writing the data
write
(String
The remote file path
path
,
int
The internal write buffer size
bufferSize
,
Collection<SftpClient.OpenMode>
The remote file OpenModes
mode
)

Write to a remote file via an output stream

Inherited from org.apache.sshd.client.subsystem.SubsystemClient:
getSession