Skip to content

SSH.Get

Andrew Lambert edited this page Nov 26, 2022 · 7 revisions

SSH.Get

Method signature

 Protected Function Get(Optional Session As SSH.Session, URL As String) As SSH.SSHStream

Parameters

Name Type Comment
Session Session Optional. If specified, an active SSH session to use.
URL String The fully qualified URL to download.

Return value

An object that implements the SSHStream interface, from which the download can be read.

Remarks

This convenience method prepares a download using SFTP or SCP (specified in the URL). If the Session parameter is specified then only the path part of the URL is used.

Example

This example specifies everything in the URL

  Dim reader As SSHStream = SSH.Get("sftp://username:password@ssh.example.com:2222/pub/file.zip")
  Dim writer As BinaryStream = BinaryStream.Create(SpecialFolder.Desktop.Child("file.zip"))
  Do Until reader.EOF
    writer.Write(reader.Read(1024 * 1024))
  Loop
  reader.Close
  writer.Close

This example uses an existing session.

  Dim session As SSH.Session = SSH.Connect("ssh.example.com", 2222, "username", "password")
  Dim reader As SSHStream = SSH.Get(session, "sftp:///pub/file.zip") ' Note the triple /
  Dim writer As BinaryStream = BinaryStream.Create(SpecialFolder.Desktop.Child("file.zip"))
  Do Until reader.EOF
    writer.Write(reader.Read(1024 * 1024))
  Loop
  reader.Close
  writer.Close
Clone this wiki locally