-
-
Notifications
You must be signed in to change notification settings - Fork 4
SSH.Get
Andrew Lambert edited this page Nov 26, 2022
·
7 revisions
SSH.Get
Protected Function Get(Optional Session As SSH.Session, URL As String) As SSH.SSHStream
Name | Type | Comment |
---|---|---|
Session |
Session | Optional. If specified, an active SSH session to use. |
URL |
String | The fully qualified URL to download. |
An object that implements the SSHStream interface, from which the download can be read.
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.
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
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2018-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.