-
-
Notifications
You must be signed in to change notification settings - Fork 4
SSH.Put
Andrew Lambert edited this page Nov 26, 2022
·
5 revisions
SSH.Put
Protected Function Put(Optional Session As SSH.Session, URL As String, Length As UInt32 = 0, Overwrite As Boolean = False) As SSH.SSHStream| Name | Type | Comment |
|---|---|---|
Session |
Session | Optional. If specified, an active SSH session to use. |
URL |
String | The fully qualified URL to upload to. |
Length |
UInt32 | The total number of bytes which will be uploaded. Optional for SFTP, mandatory for SCP |
Overwrite |
Boolean | Optional. If True, then the remote file will be overwritten if it exists. |
An object that implements the SSHStream interface, to which the upload data can be written.
This convenience method prepares an upload 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 writer As SSHStream = SSH.Put("sftp://username:password@ssh.example.com:2222/pub/file.zip")
Dim reader As BinaryStream = BinaryStream.Open(SpecialFolder.Desktop.Child("file.zip"))
Do Until reader.EOF
writer.Write(reader.Read(1024 * 64))
Loop
reader.Close
writer.CloseThis example uses an existing session.
Dim session As SSH.Session = SSH.Connect("ssh.example.com", 2222, "username", "password")
Dim writer As SSHStream = SSH.Put(session, "sftp:///pub/file.zip") ' Note the triple /
Dim reader As BinaryStream = BinaryStream.Open(SpecialFolder.Desktop.Child("file.zip"))
Do Until reader.EOF
writer.Write(reader.Read(1024 * 64))
Loop
reader.Close
writer.CloseWiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2018-26 Andrew Lambert, offered under the CC BY-SA 3.0 License.