0 votes
by (260 points)

If I understand the Rebex SFTP documentation correctly, the GetFileAsync, PutAsync and GetListAsync can be cancelled with the AbortTransfer method.

It would be great if those methods (and probably more) would have an overload with a CancellationToken, making it consistent with the .NET Framework APIs.

As a workaround, I created wrapper methods which internally work like this:

var state = Guid.NewGuid();
using (cancellationToken.Register(() => sftp.AbortTransfer(state)))
    await sftp.PutFileAsync(stream, remotePath, state);

Is this correct usage of the state / AbortTransfer? Unfortunately, the documentation is a little bit thin here.

Thank you in advance!

Applies to: Rebex SFTP

1 Answer

0 votes
by (132k points)
selected by
Best answer

Yes, your code is a nice workaround for lack of CancellationToken support.

We plan to extend Rebex SFTP API to support CancellationToken for methods that can be canceled using AbortTransfer method - most likely with the next major update of our API next year.

by (260 points)
Great, thank you!