From 07e3bf33112d93c387b445a75faec3421b12a20d Mon Sep 17 00:00:00 2001 From: Olle Kelderman Date: Fri, 23 Mar 2018 17:46:29 +0100 Subject: [PATCH] add call to GetReply after using OpenRead or OpenWrite according to FluentFTP documentation --- ShareX.UploadersLib/FileUploaders/FTP.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ShareX.UploadersLib/FileUploaders/FTP.cs b/ShareX.UploadersLib/FileUploaders/FTP.cs index a94841728..a8be9ed1d 100644 --- a/ShareX.UploadersLib/FileUploaders/FTP.cs +++ b/ShareX.UploadersLib/FileUploaders/FTP.cs @@ -231,10 +231,7 @@ public bool UploadData(Stream localStream, string remotePath) { try { - using (Stream remoteStream = client.OpenWrite(remotePath)) - { - return TransferData(localStream, remoteStream); - } + return UploadData2(localStream, remotePath); } catch (FtpCommandException e) { @@ -243,10 +240,7 @@ public bool UploadData(Stream localStream, string remotePath) { CreateMultiDirectory(URLHelpers.GetDirectoryPath(remotePath)); - using (Stream remoteStream = client.OpenWrite(remotePath)) - { - return TransferData(localStream, remoteStream); - } + return UploadData2(localStream, remotePath); } throw e; @@ -256,6 +250,17 @@ public bool UploadData(Stream localStream, string remotePath) return false; } + private bool UploadData2(Stream localStream, string remotePath) + { + bool result; + using (Stream remoteStream = client.OpenWrite(remotePath)) + { + result = TransferData(localStream, remoteStream); + } + FtpReply ftpReply = client.GetReply(); + return result && ftpReply.Success; + } + public void UploadData(byte[] data, string remotePath) { using (MemoryStream stream = new MemoryStream(data, false)) @@ -322,6 +327,7 @@ public void DownloadFile(string remotePath, Stream localStream) { TransferData(remoteStream, localStream); } + client.GetReply(); } }