public void Upload(Stream inStream, Stream outStream, string fileName) { _client.Connect(); if (_client.IsConnected) { _client.BufferSize = 4 * 1024;// bypass Payload error large files _client.UploadFile(inStream, fileName); if (_client.Exists(fileName)) { var confirmation = new Confirmation { HostName = _client.ConnectionInfo.Host, FileName = fileName, FileSize = _client.GetAttributes(fileName).Size }; var outJson = JToken.FromObject(confirmation).ToString(); using (var b = new StreamWriter(outStream, Encoding.UTF8, 1000, true)) { b.Write(outJson); b.Flush(); } } } else { throw new IOException($"Cannot connect to {_client.ConnectionInfo.Host}"); } }