+1 vote
by (270 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 (134k 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 (270 points)
Great, thank you!
by (170 points)
Am I missing something, or is this still missing in the API?
by (134k points)
Still missing for now, unfortunately. We have not been progressing as quickly as expected during the pandemic, and some non-essential features have been postponed.
...