Last active
July 29, 2024 00:15
-
-
Save sanisoclem/cd2a6c93ec9a56f191883cbbe9cf26fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! "net8" | |
#r "nuget: SSH.NET, 2024.1.0" | |
using Renci.SshNet; | |
using System.Text; | |
var pk = "PK_IN_PEM_FORMAT"; | |
var memPk = new MemoryStream(Encoding.ASCII.GetBytes(pk)); | |
var auth = new PrivateKeyAuthenticationMethod("jerahmeel-test", new PrivateKeyFile(memPk)); | |
var connectionInfo = new ConnectionInfo("sft.creditclear.com.au", "jerahmeel-test", [auth]); | |
var data = string.Join('\n', Enumerable.Range(0, 10000).Select(i => Random.Shared.NextInt64().ToString()).ToArray()); | |
using var client = new SftpClient(connectionInfo); | |
client.Connect(); | |
// create a file | |
var handle = client.Create("test-dont-close.txt"); | |
handle.Write(Encoding.UTF8.GetBytes(data).AsSpan()); | |
// not closing before disconnecting causes the issue | |
// no error is raised in the client, but file is not uploaded to server | |
//handle.Close(); | |
client.Disconnect(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment