Package org.apache.sshd.sftp.client
Interface SftpClient
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.nio.channels.Channel
,ChannelHolder
,ClientChannelHolder
,ClientSessionHolder
,java.io.Closeable
,NamedResource
,SessionContextHolder
,SessionHolder<ClientSession>
,SubsystemClient
- All Known Subinterfaces:
FullAccessSftpClient
- All Known Implementing Classes:
AbstractSftpClient
,DefaultSftpClient
,SftpFileSystem.Wrapper
public interface SftpClient extends SubsystemClient
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
SftpClient.Attribute
static class
SftpClient.Attributes
static class
SftpClient.CloseableHandle
static class
SftpClient.CopyMode
static class
SftpClient.DirEntry
static class
SftpClient.Handle
static class
SftpClient.OpenMode
-
Field Summary
Fields Modifier and Type Field Description static java.util.Set<SftpClient.OpenMode>
DEFAULT_CHANNEL_MODES
Default modes for opening a channel if no specific modes specifiedstatic SftpClient.DirEntry[]
EMPTY_DIR_ENTRIES
static int
IO_BUFFER_SIZE
static int
MIN_BUFFER_SIZE
static int
MIN_READ_BUFFER_SIZE
static int
MIN_WRITE_BUFFER_SIZE
-
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.String
canonicalPath(java.lang.String path)
The effective "normalized" remote pathvoid
close(SftpClient.Handle handle)
Close the handle obtained from one of theopen
methodsdefault <E extends SftpClientExtension>
EgetExtension(java.lang.Class<? extends E> extensionType)
default SftpClientExtension
getExtension(java.lang.String extensionName)
SftpClientExtension
getExtension(SftpClientExtensionFactory factory)
default java.lang.String
getName()
java.nio.charset.Charset
getNameDecodingCharset()
java.util.NavigableMap<java.lang.String,byte[]>
getServerExtensions()
int
getVersion()
boolean
isClosing()
void
link(java.lang.String linkPath, java.lang.String targetPath, boolean symbolic)
Create a linkjava.lang.Iterable<SftpClient.DirEntry>
listDir(SftpClient.Handle handle)
void
lock(SftpClient.Handle handle, long offset, long length, int mask)
SftpClient.Attributes
lstat(java.lang.String path)
Retrieve remote path meta-data - do not follow symbolic linksvoid
mkdir(java.lang.String path)
Create remote directorydefault SftpClient.CloseableHandle
open(java.lang.String path)
Opens a remote file for readSftpClient.CloseableHandle
open(java.lang.String path, java.util.Collection<SftpClient.OpenMode> options)
Opens a remote file with the specified mode(s)default SftpClient.CloseableHandle
open(java.lang.String path, SftpClient.OpenMode... options)
Opens a remote file with the specified mode(s)SftpClient.CloseableHandle
openDir(java.lang.String path)
Obtain a handle for a directoryjava.nio.channels.FileChannel
openRemoteFileChannel(java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes)
Opens anFileChannel
on the specified remote pathdefault java.nio.channels.FileChannel
openRemoteFileChannel(java.lang.String path, SftpClient.OpenMode... modes)
default java.nio.channels.FileChannel
openRemotePathChannel(java.lang.String path, java.nio.file.OpenOption... options)
default java.nio.channels.FileChannel
openRemotePathChannel(java.lang.String path, java.util.Collection<? extends java.nio.file.OpenOption> options)
default void
put(java.io.InputStream stream, int bufferSize, java.lang.String path)
void
put(java.io.InputStream stream, int bufferSize, java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes)
Write data from anInputStream
to a remote file.default void
put(java.io.InputStream stream, int bufferSize, java.lang.String path, SftpClient.OpenMode... modes)
default void
put(java.io.InputStream stream, java.lang.String path)
default void
put(java.io.InputStream stream, java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes)
default void
put(java.io.InputStream stream, java.lang.String path, SftpClient.OpenMode... modes)
default void
put(java.nio.file.Path localFile, int bufferSize, java.lang.String path)
default void
put(java.nio.file.Path localFile, int bufferSize, java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes)
Uploads a local file to a remote file.default void
put(java.nio.file.Path localFile, int bufferSize, java.lang.String path, SftpClient.OpenMode... modes)
default void
put(java.nio.file.Path localFile, java.lang.String path)
default void
put(java.nio.file.Path localFile, java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes)
default void
put(java.nio.file.Path localFile, java.lang.String path, SftpClient.OpenMode... modes)
default java.io.InputStream
read(java.lang.String path)
default java.io.InputStream
read(java.lang.String path, int bufferSize)
java.io.InputStream
read(java.lang.String path, int bufferSize, java.util.Collection<SftpClient.OpenMode> mode)
Read a remote file's data via an input streamdefault java.io.InputStream
read(java.lang.String path, int bufferSize, SftpClient.OpenMode... mode)
default java.io.InputStream
read(java.lang.String path, java.util.Collection<SftpClient.OpenMode> mode)
default java.io.InputStream
read(java.lang.String path, SftpClient.OpenMode... mode)
default int
read(SftpClient.Handle handle, long fileOffset, byte[] dst)
Reads data from the open (file) handledefault int
read(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len)
int
read(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len, java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> eofSignalled)
Reads data from the open (file) handledefault int
read(SftpClient.Handle handle, long fileOffset, byte[] dst, java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> eofSignalled)
Reads data from the open (file) handlejava.lang.Iterable<SftpClient.DirEntry>
readDir(java.lang.String path)
default java.util.List<SftpClient.DirEntry>
readDir(SftpClient.Handle handle)
java.util.List<SftpClient.DirEntry>
readDir(SftpClient.Handle handle, java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> eolIndicator)
default java.util.Collection<SftpClient.DirEntry>
readEntries(java.lang.String path)
Reads all entries available for a directoryjava.lang.String
readLink(java.lang.String path)
Retrieve target of a linkvoid
remove(java.lang.String path)
default void
rename(java.lang.String oldPath, java.lang.String newPath)
void
rename(java.lang.String oldPath, java.lang.String newPath, java.util.Collection<SftpClient.CopyMode> options)
default void
rename(java.lang.String oldPath, java.lang.String newPath, SftpClient.CopyMode... options)
void
rmdir(java.lang.String path)
Remove remote directoryvoid
setNameDecodingCharset(java.nio.charset.Charset cs)
void
setStat(java.lang.String path, SftpClient.Attributes attributes)
Update remote node meta-datavoid
setStat(SftpClient.Handle handle, SftpClient.Attributes attributes)
Update remote node meta-datadefault SftpClient
singleSessionInstance()
Creates anSftpClient
instance that also closes the underlyingclient session
when the client instance is closed.SftpClient.Attributes
stat(java.lang.String path)
Retrieve remote path meta-data - follow symbolic links if encounteredSftpClient.Attributes
stat(SftpClient.Handle handle)
Retrieve file/directory handle meta-datadefault void
symLink(java.lang.String linkPath, java.lang.String targetPath)
Create symbolic linkvoid
unlock(SftpClient.Handle handle, long offset, long length)
default java.io.OutputStream
write(java.lang.String path)
default java.io.OutputStream
write(java.lang.String path, int bufferSize)
java.io.OutputStream
write(java.lang.String path, int bufferSize, java.util.Collection<SftpClient.OpenMode> mode)
Write to a remote file via an output streamdefault java.io.OutputStream
write(java.lang.String path, int bufferSize, SftpClient.OpenMode... mode)
default java.io.OutputStream
write(java.lang.String path, java.util.Collection<SftpClient.OpenMode> mode)
default java.io.OutputStream
write(java.lang.String path, SftpClient.OpenMode... mode)
default void
write(SftpClient.Handle handle, long fileOffset, byte[] src)
void
write(SftpClient.Handle handle, long fileOffset, byte[] src, int srcOffset, int len)
Write data to (open) file handle-
Methods inherited from interface org.apache.sshd.client.channel.ClientChannelHolder
getChannel, getClientChannel
-
Methods inherited from interface org.apache.sshd.client.session.ClientSessionHolder
getClientSession
-
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
Methods inherited from interface org.apache.sshd.client.subsystem.SubsystemClient
getSession
-
-
-
-
Field Detail
-
EMPTY_DIR_ENTRIES
static final SftpClient.DirEntry[] EMPTY_DIR_ENTRIES
-
MIN_BUFFER_SIZE
static final int MIN_BUFFER_SIZE
- See Also:
- Constant Field Values
-
MIN_READ_BUFFER_SIZE
static final int MIN_READ_BUFFER_SIZE
- See Also:
- Constant Field Values
-
MIN_WRITE_BUFFER_SIZE
static final int MIN_WRITE_BUFFER_SIZE
- See Also:
- Constant Field Values
-
IO_BUFFER_SIZE
static final int IO_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_CHANNEL_MODES
static final java.util.Set<SftpClient.OpenMode> DEFAULT_CHANNEL_MODES
Default modes for opening a channel if no specific modes specified
-
-
Method Detail
-
getVersion
int getVersion()
- Returns:
- The negotiated SFTP protocol version
-
getName
default java.lang.String getName()
- Specified by:
getName
in interfaceNamedResource
- Returns:
- The resource name
-
getNameDecodingCharset
java.nio.charset.Charset getNameDecodingCharset()
- Returns:
- The (never
null
)Charset
used to decode referenced files/folders names - See Also:
SftpModuleProperties.NAME_DECODING_CHARSET
-
setNameDecodingCharset
void setNameDecodingCharset(java.nio.charset.Charset cs)
-
getServerExtensions
java.util.NavigableMap<java.lang.String,byte[]> getServerExtensions()
- Returns:
- An (unmodifiable)
NavigableMap
of the reported server extensions. where key=extension name (case insensitive)
-
isClosing
boolean isClosing()
-
open
default SftpClient.CloseableHandle open(java.lang.String path) throws java.io.IOException
Opens a remote file for read- Parameters:
path
- The remote path- Returns:
- The file's
SftpClient.CloseableHandle
- Throws:
java.io.IOException
- If failed to open the remote file- See Also:
open(String, Collection)
-
open
default SftpClient.CloseableHandle open(java.lang.String path, SftpClient.OpenMode... options) throws java.io.IOException
Opens a remote file with the specified mode(s)- Parameters:
path
- The remote pathoptions
- The desired mode - if none specified thenSftpClient.OpenMode.Read
is assumed- Returns:
- The file's
SftpClient.CloseableHandle
- Throws:
java.io.IOException
- If failed to open the remote file- See Also:
open(String, Collection)
-
open
SftpClient.CloseableHandle open(java.lang.String path, java.util.Collection<SftpClient.OpenMode> options) throws java.io.IOException
Opens a remote file with the specified mode(s)- Parameters:
path
- The remote pathoptions
- The desired mode - if none specified thenSftpClient.OpenMode.Read
is assumed- Returns:
- The file's
SftpClient.CloseableHandle
- Throws:
java.io.IOException
- If failed to open the remote file
-
close
void close(SftpClient.Handle handle) throws java.io.IOException
Close the handle obtained from one of theopen
methods- Parameters:
handle
- TheHandle
to close- Throws:
java.io.IOException
- If failed to execute
-
remove
void remove(java.lang.String path) throws java.io.IOException
- Parameters:
path
- The remote path to remove- Throws:
java.io.IOException
- If failed to execute
-
rename
default void rename(java.lang.String oldPath, java.lang.String newPath) throws java.io.IOException
- Throws:
java.io.IOException
-
rename
default void rename(java.lang.String oldPath, java.lang.String newPath, SftpClient.CopyMode... options) throws java.io.IOException
- Throws:
java.io.IOException
-
rename
void rename(java.lang.String oldPath, java.lang.String newPath, java.util.Collection<SftpClient.CopyMode> options) throws java.io.IOException
- Throws:
java.io.IOException
-
read
default int read(SftpClient.Handle handle, long fileOffset, byte[] dst) throws java.io.IOException
Reads data from the open (file) handle- Parameters:
handle
- The fileSftpClient.Handle
to read fromfileOffset
- The file offset to read fromdst
- The destination buffer- Returns:
- Number of read bytes -
-1
if EOF reached - Throws:
java.io.IOException
- If failed to read the data- See Also:
read(Handle, long, byte[], int, int)
-
read
default int read(SftpClient.Handle handle, long fileOffset, byte[] dst, java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> eofSignalled) throws java.io.IOException
Reads data from the open (file) handle- Parameters:
handle
- The fileSftpClient.Handle
to read fromfileOffset
- The file offset to read fromdst
- The destination buffereofSignalled
- If notnull
then upon return holds a value indicating whether EOF was reached due to the read. Ifnull
indicator value then this indication is not available- Returns:
- Number of read bytes -
-1
if EOF reached - Throws:
java.io.IOException
- If failed to read the data- See Also:
read(Handle, long, byte[], int, int, AtomicReference)
, SFTP v6 - section 9.3
-
read
default int read(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
read
int read(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len, java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> eofSignalled) throws java.io.IOException
Reads data from the open (file) handle- Parameters:
handle
- The fileSftpClient.Handle
to read fromfileOffset
- The file offset to read fromdst
- The destination bufferdstOffset
- Offset in destination buffer to place the read datalen
- Available destination buffer size to readeofSignalled
- If notnull
then upon return holds a value indicating whether EOF was reached due to the read. Ifnull
indicator value then this indication is not available- Returns:
- Number of read bytes -
-1
if EOF reached - Throws:
java.io.IOException
- If failed to read the data- See Also:
- SFTP v6 - section 9.3
-
write
default void write(SftpClient.Handle handle, long fileOffset, byte[] src) throws java.io.IOException
- Throws:
java.io.IOException
-
write
void write(SftpClient.Handle handle, long fileOffset, byte[] src, int srcOffset, int len) throws java.io.IOException
Write data to (open) file handle- Parameters:
handle
- The fileSftpClient.Handle
fileOffset
- Zero-based offset to write in filesrc
- Data buffersrcOffset
- Offset of valid data in bufferlen
- Number of bytes to write- Throws:
java.io.IOException
- If failed to write the data
-
mkdir
void mkdir(java.lang.String path) throws java.io.IOException
Create remote directory- Parameters:
path
- Remote directory path- Throws:
java.io.IOException
- If failed to execute
-
rmdir
void rmdir(java.lang.String path) throws java.io.IOException
Remove remote directory- Parameters:
path
- Remote directory path- Throws:
java.io.IOException
- If failed to execute
-
openDir
SftpClient.CloseableHandle openDir(java.lang.String path) throws java.io.IOException
Obtain a handle for a directory- Parameters:
path
- Remote directory path- Returns:
- The associated directory
SftpClient.Handle
- Throws:
java.io.IOException
- If failed to execute
-
readDir
default java.util.List<SftpClient.DirEntry> readDir(SftpClient.Handle handle) throws java.io.IOException
- Parameters:
handle
- DirectorySftpClient.Handle
to read from- 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 (untilnull
). In order to iterate over all the entries usereadDir(String)
- Throws:
java.io.IOException
- If failed to access the remote site
-
readDir
java.util.List<SftpClient.DirEntry> readDir(SftpClient.Handle handle, java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> eolIndicator) throws java.io.IOException
- Parameters:
handle
- DirectorySftpClient.Handle
to read fromeolIndicator
- An indicator that can be used to get information whether end of list has been reached - ignored ifnull
. Upon return, set value indicates whether all entries have been exhausted - anull
value means that this information cannot be provided and another call toreadDir
is necessary in order to verify that no more entries are pending- Returns:
- A
List
of entries -null
to indicate no more entries - Throws:
java.io.IOException
- If failed to access the remote site- See Also:
- SFTP v6 - section 9.4
-
listDir
java.lang.Iterable<SftpClient.DirEntry> listDir(SftpClient.Handle handle) throws java.io.IOException
- Parameters:
handle
- A directorySftpClient.Handle
- Returns:
- An
Iterable
that can be used to iterate over all the directory entries (likereadDir(String)
). Note: the iterable instance is not re-usable - i.e., files can be iterated only once - Throws:
java.io.IOException
- If failed to access the directory
-
canonicalPath
java.lang.String canonicalPath(java.lang.String path) throws java.io.IOException
The effective "normalized" remote path- Parameters:
path
- The requested path - may be relative, and/or contain dots - e.g., ".", "..", "./foo", "../bar"- Returns:
- The effective "normalized" remote path
- Throws:
java.io.IOException
- If failed to execute
-
stat
SftpClient.Attributes stat(java.lang.String path) throws java.io.IOException
Retrieve remote path meta-data - follow symbolic links if encountered- Parameters:
path
- The remote path- Returns:
- The associated
SftpClient.Attributes
- Throws:
java.io.IOException
- If failed to execute
-
lstat
SftpClient.Attributes lstat(java.lang.String path) throws java.io.IOException
Retrieve remote path meta-data - do not follow symbolic links- Parameters:
path
- The remote path- Returns:
- The associated
SftpClient.Attributes
- Throws:
java.io.IOException
- If failed to execute
-
stat
SftpClient.Attributes stat(SftpClient.Handle handle) throws java.io.IOException
Retrieve file/directory handle meta-data- Parameters:
handle
- TheSftpClient.Handle
obtained via one of theopen
calls- Returns:
- The associated
SftpClient.Attributes
- Throws:
java.io.IOException
- If failed to execute
-
setStat
void setStat(java.lang.String path, SftpClient.Attributes attributes) throws java.io.IOException
Update remote node meta-data- Parameters:
path
- The remote pathattributes
- TheSftpClient.Attributes
to update- Throws:
java.io.IOException
- If failed to execute
-
setStat
void setStat(SftpClient.Handle handle, SftpClient.Attributes attributes) throws java.io.IOException
Update remote node meta-data- Parameters:
handle
- TheSftpClient.Handle
obtained via one of theopen
callsattributes
- TheSftpClient.Attributes
to update- Throws:
java.io.IOException
- If failed to execute
-
readLink
java.lang.String readLink(java.lang.String path) throws java.io.IOException
Retrieve target of a link- Parameters:
path
- Remote path that represents a link- Returns:
- The link target
- Throws:
java.io.IOException
- If failed to execute
-
symLink
default void symLink(java.lang.String linkPath, java.lang.String targetPath) throws java.io.IOException
Create symbolic link- Parameters:
linkPath
- The link locationtargetPath
- The referenced target by the link- Throws:
java.io.IOException
- If failed to execute- See Also:
link(String, String, boolean)
-
link
void link(java.lang.String linkPath, java.lang.String targetPath, boolean symbolic) throws java.io.IOException
Create a link- Parameters:
linkPath
- The link locationtargetPath
- The referenced target by the linksymbolic
- Iftrue
then make this a symbolic link, otherwise a hard one- Throws:
java.io.IOException
- If failed to execute
-
lock
void lock(SftpClient.Handle handle, long offset, long length, int mask) throws java.io.IOException
- Throws:
java.io.IOException
-
unlock
void unlock(SftpClient.Handle handle, long offset, long length) throws java.io.IOException
- Throws:
java.io.IOException
-
openRemotePathChannel
default java.nio.channels.FileChannel openRemotePathChannel(java.lang.String path, java.nio.file.OpenOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
openRemotePathChannel
default java.nio.channels.FileChannel openRemotePathChannel(java.lang.String path, java.util.Collection<? extends java.nio.file.OpenOption> options) throws java.io.IOException
- Throws:
java.io.IOException
-
openRemoteFileChannel
default java.nio.channels.FileChannel openRemoteFileChannel(java.lang.String path, SftpClient.OpenMode... modes) throws java.io.IOException
- Throws:
java.io.IOException
-
openRemoteFileChannel
java.nio.channels.FileChannel openRemoteFileChannel(java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes) throws java.io.IOException
Opens anFileChannel
on the specified remote path- Parameters:
path
- The remote pathmodes
- The access mode(s) - ifnull
/empty then theDEFAULT_CHANNEL_MODES
are used- 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. - Throws:
java.io.IOException
- If failed to open the channel- See Also:
Channels.newInputStream(java.nio.channels.ReadableByteChannel)
,Channels.newOutputStream(java.nio.channels.WritableByteChannel)
-
readDir
java.lang.Iterable<SftpClient.DirEntry> readDir(java.lang.String path) throws java.io.IOException
- Parameters:
path
- The remote directory path- Returns:
- An
Iterable
that can be used to iterate over all the directory entries (unlikereadDir(Handle)
) - Throws:
java.io.IOException
- If failed to access the remote site- See Also:
readDir(Handle)
-
readEntries
default java.util.Collection<SftpClient.DirEntry> readEntries(java.lang.String path) throws java.io.IOException
Reads all entries available for a directory- Parameters:
path
- Remote directory path- Returns:
- A
Collection
of all the entries in the remote directory - Throws:
java.io.IOException
- If failed to retrieve the entries- See Also:
readDir(String)
-
read
default java.io.InputStream read(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
read
default java.io.InputStream read(java.lang.String path, int bufferSize) throws java.io.IOException
- Throws:
java.io.IOException
-
read
default java.io.InputStream read(java.lang.String path, SftpClient.OpenMode... mode) throws java.io.IOException
- Throws:
java.io.IOException
-
read
default java.io.InputStream read(java.lang.String path, int bufferSize, SftpClient.OpenMode... mode) throws java.io.IOException
- Throws:
java.io.IOException
-
read
default java.io.InputStream read(java.lang.String path, java.util.Collection<SftpClient.OpenMode> mode) throws java.io.IOException
- Throws:
java.io.IOException
-
read
java.io.InputStream read(java.lang.String path, int bufferSize, java.util.Collection<SftpClient.OpenMode> mode) throws java.io.IOException
Read a remote file's data via an input stream- Parameters:
path
- The remote file pathbufferSize
- The internal read buffer sizemode
- The remote fileSftpClient.OpenMode
s- Returns:
- An
InputStream
for reading the remote file data - Throws:
java.io.IOException
- If failed to execute
-
write
default java.io.OutputStream write(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
write
default java.io.OutputStream write(java.lang.String path, int bufferSize) throws java.io.IOException
- Throws:
java.io.IOException
-
write
default java.io.OutputStream write(java.lang.String path, SftpClient.OpenMode... mode) throws java.io.IOException
- Throws:
java.io.IOException
-
write
default java.io.OutputStream write(java.lang.String path, int bufferSize, SftpClient.OpenMode... mode) throws java.io.IOException
- Throws:
java.io.IOException
-
write
default java.io.OutputStream write(java.lang.String path, java.util.Collection<SftpClient.OpenMode> mode) throws java.io.IOException
- Throws:
java.io.IOException
-
write
java.io.OutputStream write(java.lang.String path, int bufferSize, java.util.Collection<SftpClient.OpenMode> mode) throws java.io.IOException
Write to a remote file via an output stream- Parameters:
path
- The remote file pathbufferSize
- The internal write buffer sizemode
- The remote fileSftpClient.OpenMode
s- Returns:
- An
OutputStream
for writing the data - Throws:
java.io.IOException
- If failed to execute
-
put
default void put(java.nio.file.Path localFile, java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.io.InputStream stream, java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.nio.file.Path localFile, int bufferSize, java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.io.InputStream stream, int bufferSize, java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.nio.file.Path localFile, java.lang.String path, SftpClient.OpenMode... modes) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.io.InputStream stream, java.lang.String path, SftpClient.OpenMode... modes) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.nio.file.Path localFile, int bufferSize, java.lang.String path, SftpClient.OpenMode... modes) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.io.InputStream stream, int bufferSize, java.lang.String path, SftpClient.OpenMode... modes) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.nio.file.Path localFile, java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.io.InputStream stream, java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes) throws java.io.IOException
- Throws:
java.io.IOException
-
put
default void put(java.nio.file.Path localFile, int bufferSize, java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes) throws java.io.IOException
Uploads a local file to a remote file.- Parameters:
localFile
-Path
of the local file to uploadbufferSize
- 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.path
- The remote file pathmode
- The remote fileSftpClient.OpenMode
s- Throws:
java.io.IOException
- if data cannot be read, or cannot be written
-
put
void put(java.io.InputStream stream, int bufferSize, java.lang.String path, java.util.Collection<SftpClient.OpenMode> modes) throws java.io.IOException
Write data from anInputStream
to a remote file.- Parameters:
stream
-InputStream
to read frombufferSize
- 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.path
- The remote file pathmode
- The remote fileSftpClient.OpenMode
s- Throws:
java.io.IOException
- if data cannot be read, or cannot be written
-
getExtension
default <E extends SftpClientExtension> E getExtension(java.lang.Class<? extends E> extensionType)
- Type Parameters:
E
- The generic extension type- Parameters:
extensionType
- The extension type- Returns:
- The extension instance - Note: it is up to the caller to invoke
OptionalFeature.isSupported()
-null
if this extension type is not implemented by the client - See Also:
getServerExtensions()
-
getExtension
default SftpClientExtension getExtension(java.lang.String extensionName)
- Parameters:
extensionName
- The extension name- Returns:
- The extension instance - Note: it is up to the caller to invoke
OptionalFeature.isSupported()
-null
if this extension type is not implemented by the client - See Also:
getServerExtensions()
-
getExtension
SftpClientExtension getExtension(SftpClientExtensionFactory factory)
- Parameters:
factory
- TheSftpClientExtensionFactory
instance to use - ignored ifnull
- Returns:
- The extension instance - Note: it is up to the caller to invoke
OptionalFeature.isSupported()
-null
if this extension type is not implemented by the client
-
singleSessionInstance
default SftpClient singleSessionInstance()
Creates anSftpClient
instance that also closes the underlyingclient session
when the client instance is closed.- Returns:
- The wrapper instance
-
-