Skip to content

Instantly share code, notes, and snippets.

public static class SftpExtensions
{
/// <remarks>
/// unfortunately the ssh library doesn't expose a modern async api
/// that supports cancellation via CancellationToken
/// so we have to wrap the APM pattern with a TaskCompletionSource
/// </remarks>
public static Task UploadFileAsync(this SftpClient sftpClient, Stream input, string path, bool canOverride, Action<ulong> uploadCallback = null, CancellationToken cancellationToken = default(CancellationToken))
{
var tcs = new TaskCompletionSource<SftpUploadAsyncResult>();