ScpToMessageBySftp (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.taskdefs.optional.ssh, class: ScpToMessageBySftp

# Class ScpToMessageBySftp

java.lang.Object
org.apache.tools.ant.taskdefs.optional.ssh.AbstractSshMessage
org.apache.tools.ant.taskdefs.optional.ssh.ScpToMessage
org.apache.tools.ant.taskdefs.optional.ssh.ScpToMessageBySftp

public class ScpToMessageBySftp extends ScpToMessage
Utility class to carry out an upload by sftp.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ScpToMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, File aLocalFile, String aRemotePath)`
  Constructor for a local file to remote.
  `ScpToMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, File aLocalFile, String aRemotePath, boolean preserveLastModified)`
  Constructor for a local file to remote.
  `ScpToMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, List<Directory> aDirectoryList, String aRemotePath)`
  Constructor for a local directories to remote.
  `ScpToMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, List<Directory> aDirectoryList, String aRemotePath, boolean preserveLastModified)`
  Constructor for a local directories to remote.
  `ScpToMessageBySftp(com.jcraft.jsch.Session session, File aLocalFile, String aRemotePath)`
  Constructor for ScpToMessage.
  `ScpToMessageBySftp(com.jcraft.jsch.Session session, List<Directory> aDirectoryList, String aRemotePath)`
  Constructor for ScpToMessage.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `execute()`
  Carry out the transfer.
  `File`
  `getLocalFile()`
  Get the local file.
  `boolean`
  `getPreserveLastModified()`
  Returns true if the last modified time needs to be preserved on the file(s) that get transferred.
  `String`
  `getRemotePath()`
  Get the remote path.

  ### Methods inherited from class ScpToMessage

  `getDirMode, getFileMode, setDirMode, setFileMode`
  Modifier and Type
  Method
  Description
  `int`
  `getDirMode()`
  Get the dir mode.
  `int`
  `getFileMode()`
  Get the file mode.
  `void`
  `setDirMode(int dirMode)`
  Set the dir mode, defaults to 0755.
  `void`
  `setFileMode(int fileMode)`
  Set the file mode, defaults to 0644.

  ### Methods inherited from class AbstractSshMessage

  `getCompressed, getProgressMonitor, getVerbose, log, logStats, openExecChannel, openSftpChannel, sendAck, setLogListener, trackProgress, waitForAck`
  Modifier and Type
  Method
  Description
  `protected final boolean`
  `getCompressed()`
  Is the compressed attribute set.
  `protected com.jcraft.jsch.SftpProgressMonitor`
  `getProgressMonitor()`
  Get the progress monitor.
  `protected final boolean`
  `getVerbose()`
  Is the verbose attribute set.
  `protected void`
  `log(String message)`
  Log a message to the log listener.
  `protected void`
  `logStats(long timeStarted, long timeEnded, long totalLength)`
  Log transfer stats to the log listener.
  `protected com.jcraft.jsch.Channel`
  `openExecChannel(String command)`
  Open an ssh channel.
  `protected com.jcraft.jsch.ChannelSftp`
  `openSftpChannel()`
  Open an ssh sftp channel.
  `protected void`
  `sendAck(OutputStream out)`
  Send an ack.
  `void`
  `setLogListener(LogListener aListener)`
  Set a log listener.
  `protected final int`
  `trackProgress(long filesize, long totalLength, int percentTransmitted)`
  Track progress every 10% if 100kb < filesize < 1Mb.
  `protected void`
  `waitForAck(InputStream in)`
  Reads the response, throws a BuildException if the response indicates an error.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ScpToMessageBySftp

    public ScpToMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, File aLocalFile, String aRemotePath)
    Constructor for a local file to remote.
    Parameters:
      `verbose` - if true do verbose logging
      `session` - the scp session to use
      `aLocalFile` - the local file
      `aRemotePath` - the remote path
    Since:
      Ant 1.7

  - ### ScpToMessageBySftp

    public ScpToMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, File aLocalFile, String aRemotePath, boolean preserveLastModified)
    Constructor for a local file to remote.
    Parameters:
      `verbose` - if true do verbose logging
      `session` - the scp session to use
      `aLocalFile` - the local file
      `aRemotePath` - the remote path
      `preserveLastModified` - True if the last modified time needs to be preserved on the transferred files. False otherwise.
    Since:
      Ant 1.9.10

  - ### ScpToMessageBySftp

    public ScpToMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, List<Directory> aDirectoryList, String aRemotePath)
    Constructor for a local directories to remote.
    Parameters:
      `verbose` - if true do verbose logging
      `session` - the scp session to use
      `aDirectoryList` - a list of directories
      `aRemotePath` - the remote path
    Since:
      Ant 1.7

  - ### ScpToMessageBySftp

    public ScpToMessageBySftp(boolean verbose, com.jcraft.jsch.Session session, List<Directory> aDirectoryList, String aRemotePath, boolean preserveLastModified)
    Constructor for a local directories to remote.
    Parameters:
      `verbose` - if true do verbose logging
      `session` - the scp session to use
      `aDirectoryList` - a list of directories
      `aRemotePath` - the remote path
      `preserveLastModified` - True if the last modified time needs to be preserved on the transferred files. False otherwise.
    Since:
      Ant 1.9.10

  - ### ScpToMessageBySftp

    public ScpToMessageBySftp(com.jcraft.jsch.Session session, File aLocalFile, String aRemotePath)
    Constructor for ScpToMessage.
    Parameters:
      `session` - the scp session to use
      `aLocalFile` - the local file
      `aRemotePath` - the remote path

  - ### ScpToMessageBySftp

    public ScpToMessageBySftp(com.jcraft.jsch.Session session, List<Directory> aDirectoryList, String aRemotePath)
    Constructor for ScpToMessage.
    Parameters:
      `session` - the scp session to use
      `aDirectoryList` - a list of directories
      `aRemotePath` - the remote path

- ## Method Details

  - ### execute

    public void execute() throws IOException, com.jcraft.jsch.JSchException
    Carry out the transfer.
    Overrides:
      `execute` in class `ScpToMessage`
    Throws:
      `IOException` - on i/o errors
      `com.jcraft.jsch.JSchException` - on errors detected by scp

  - ### getLocalFile

    public File getLocalFile()
    Get the local file.
    Overrides:
      `getLocalFile` in class `ScpToMessage`
    Returns:
      the local file.

  - ### getRemotePath

    public String getRemotePath()
    Get the remote path.
    Overrides:
      `getRemotePath` in class `ScpToMessage`
    Returns:
      the remote path.

  - ### getPreserveLastModified

    public boolean getPreserveLastModified()
    Returns true if the last modified time needs to be preserved on the file(s) that get transferred. Returns false otherwise.
    Overrides:
      `getPreserveLastModified` in class `ScpToMessage`
    Returns:
      boolean