Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Commented Unassigned: Sftp BeginUploadFile is not uploading [1629]

$
0
0
I'm trying to send file asynchronously using sftp client BeginUploadFile.
Either using stream or string path.

See 1.png and 2.png to see the IAsynResult of the callback function.

I'm using it with dotnet 3.5

```
private void SendXmlFile(XDocument xDocument)
{
var fileName = GenerateFileName();

using (var client = new SftpClient("127.0.0.1", 990, "user01", "us3r01"))
{
client.Connect();

var stream = CreateStream(xDocument);
client.BeginUploadFile(stream, fileName, UploadCompleted);

client.Disconnect();
}
}
```
Comments: ** Comment from web user: corriveaujc **

I may be confused, but if no exception occurs, it still returns false?

```
public IAsyncResult BeginUploadFile(Stream input, string path, bool canOverride, AsyncCallback asyncCallback, object state, Action<ulong> uploadCallback = null)
{
if (input == null)
throw new ArgumentNullException("input");

if (path.IsNullOrWhiteSpace())
throw new ArgumentException("path");

var flags = Flags.Write | Flags.Truncate;

if (canOverride)
flags |= Flags.CreateNewOrOpen;
else
flags |= Flags.CreateNew;

var asyncResult = new SftpUploadAsyncResult(asyncCallback, state);

this.ExecuteThread(() =>
{
try
{
this.InternalUploadFile(input, path, flags, asyncResult, (offset) =>
{
asyncResult.Update(offset);

if (uploadCallback != null)
{
uploadCallback(offset);
}

});

__asyncResult.SetAsCompleted(null, false);__
}
catch (Exception exp)
{
asyncResult.SetAsCompleted(exp, false);
}
});

return asyncResult;
}
```


Viewing all articles
Browse latest Browse all 1026

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>