Class ChannelSftp


  • public class ChannelSftp
    extends Channel
    • Field Detail

      • SSH_FX_PERMISSION_DENIED

        public static final int SSH_FX_PERMISSION_DENIED
        See Also:
        Constant Field Values
      • agent_forwarding

        protected boolean agent_forwarding
      • xforwading

        protected boolean xforwading
      • env

        protected java.util.Hashtable<byte[],​byte[]> env
      • pty

        protected boolean pty
      • ttype

        protected java.lang.String ttype
      • tcol

        protected int tcol
      • trow

        protected int trow
      • twp

        protected int twp
      • thp

        protected int thp
      • terminal_mode

        protected byte[] terminal_mode
    • Constructor Detail

      • ChannelSftp

        public ChannelSftp()
    • Method Detail

      • setBulkRequests

        public void setBulkRequests​(int bulk_requests)
                             throws JSchException
        Specify how many requests may be sent at any one time. Increasing this value may slightly improve file transfer speed but will increase memory usage. The default is 16 requests.
        Parameters:
        bulk_requests - how many requests may be outstanding at any one time.
        Throws:
        JSchException
      • getBulkRequests

        public int getBulkRequests()
        This method will return the value how many requests may be sent at any one time.
        Returns:
        how many requests may be sent at any one time.
      • setUseWriteFlushWorkaround

        public void setUseWriteFlushWorkaround​(boolean useWriteFlushWorkaround)
      • getUseWriteFlushWorkaround

        public boolean getUseWriteFlushWorkaround()
      • quit

        public void quit()
      • exit

        public void exit()
      • put

        public void put​(java.lang.String src,
                        java.lang.String dst,
                        SftpProgressMonitor monitor,
                        int mode)
                 throws SftpException
        Sends data from src file to dst file. The mode should be OVERWRITE, RESUME or APPEND.
        Parameters:
        src - source file
        dst - destination file
        monitor - progress monitor
        mode - how data should be added to dst
        Throws:
        SftpException
      • put

        public void put​(java.io.InputStream src,
                        java.lang.String dst,
                        SftpProgressMonitor monitor,
                        int mode)
                 throws SftpException
        Sends data from the input stream src to dst file. The mode should be OVERWRITE, RESUME or APPEND.
        Parameters:
        src - input stream
        dst - destination file
        monitor - progress monitor
        mode - how data should be added to dst
        Throws:
        SftpException
      • put

        public java.io.OutputStream put​(java.lang.String dst,
                                        SftpProgressMonitor monitor,
                                        int mode,
                                        long offset)
                                 throws SftpException
        Sends data from the output stream to dst file. The mode should be OVERWRITE, RESUME or APPEND.
        Parameters:
        dst - destination file
        monitor - progress monitor
        mode - how data should be added to dst
        offset - data will be added at offset
        Returns:
        output stream, which accepts data to be transferred.
        Throws:
        SftpException
      • get

        @Deprecated
        public java.io.InputStream get​(java.lang.String src,
                                       int mode)
                                throws SftpException
        Deprecated.
        This method will be deleted in the future.
        Throws:
        SftpException
      • ls

        public void ls​(java.lang.String path,
                       ChannelSftp.LsEntrySelector selector)
                throws SftpException
        List files specified by the remote path. Each files and directories will be passed to LsEntrySelector#select(LsEntry) method, and if that method returns LsEntrySelector#BREAK, the operation will be canceled immediately.
        Throws:
        SftpException
        Since:
        0.1.47
        See Also:
        ChannelSftp.LsEntrySelector
      • symlink

        public void symlink​(java.lang.String oldpath,
                            java.lang.String newpath)
                     throws SftpException
        Throws:
        SftpException
      • hardlink

        public void hardlink​(java.lang.String oldpath,
                             java.lang.String newpath)
                      throws SftpException
        Throws:
        SftpException
      • lpwd

        public java.lang.String lpwd()
      • version

        public java.lang.String version()
      • setFilenameEncoding

        @Deprecated
        public void setFilenameEncoding​(java.lang.String encoding)
                                 throws SftpException
        Deprecated.
        Throws:
        SftpException
      • setFilenameEncoding

        public void setFilenameEncoding​(java.nio.charset.Charset encoding)
      • getExtension

        public java.lang.String getExtension​(java.lang.String key)
      • setAgentForwarding

        public void setAgentForwarding​(boolean enable)
        Enable the agent forwarding.
        Parameters:
        enable -
      • setXForwarding

        public void setXForwarding​(boolean enable)
        Enable the X11 forwarding. Refer to RFC4254 6.3.1. Requesting X11 Forwarding.
        Overrides:
        setXForwarding in class Channel
        Parameters:
        enable -
      • setEnv

        @Deprecated
        public void setEnv​(java.util.Hashtable<byte[],​byte[]> env)
        Deprecated.
        Use #setEnv(String, String) or #setEnv(byte[], byte[]) instead.
        See Also:
        setEnv(String, String), setEnv(byte[], byte[])
      • setEnv

        public void setEnv​(java.lang.String name,
                           java.lang.String value)
        Set the environment variable. If name and value are needed to be passed to the remote in your favorite encoding, use setEnv(byte[], byte[]). Refer to RFC4254 6.4 Environment Variable Passing.
        Parameters:
        name - A name for environment variable.
        value - A value for environment variable.
      • setEnv

        public void setEnv​(byte[] name,
                           byte[] value)
        Set the environment variable. Refer to RFC4254 6.4 Environment Variable Passing.
        Parameters:
        name - A name of environment variable.
        value - A value of environment variable.
        See Also:
        setEnv(String, String)
      • setPty

        public void setPty​(boolean enable)
        Allocate a Pseudo-Terminal. Refer to RFC4254 6.2. Requesting a Pseudo-Terminal.
        Parameters:
        enable -
      • setTerminalMode

        public void setTerminalMode​(byte[] terminal_mode)
        Set the terminal mode.
        Parameters:
        terminal_mode -
      • setPtySize

        public void setPtySize​(int col,
                               int row,
                               int wp,
                               int hp)
        Change the window dimension interactively. Refer to RFC4254 6.7. Window Dimension Change Message.
        Parameters:
        col - terminal width, columns
        row - terminal height, rows
        wp - terminal width, pixels
        hp - terminal height, pixels
      • setPtyType

        public void setPtyType​(java.lang.String ttype)
        Set the terminal type. This method is not effective after Channel#connect().
        Parameters:
        ttype - terminal type(for example, "vt100")
        See Also:
        setPtyType(String, int, int, int, int)
      • setPtyType

        public void setPtyType​(java.lang.String ttype,
                               int col,
                               int row,
                               int wp,
                               int hp)
        Set the terminal type. This method is not effective after Channel#connect().
        Parameters:
        ttype - terminal type(for example, "vt100")
        col - terminal width, columns
        row - terminal height, rows
        wp - terminal width, pixels
        hp - terminal height, pixels
      • sendRequests

        protected void sendRequests()
                             throws java.lang.Exception
        Throws:
        java.lang.Exception