C# FTP 上传在 Linux 环境中无法正常工作

C# FTP upload not quite working in Linux environment

我在通过 FTP

上传 JSON 文件时遇到问题
using (WebClient client = new WebClient())
{
    client.Credentials = new NetworkCredential("username", "password");
    client.UploadFile("ftp://domain.com/file.json", "STOR", "file.json");
}

在我的 (windows) 计算机上 运行 我得到 (desired)

的输出
{
    {JSON DATA}
}

但是在我的 Ubuntu 带有单声道的服务器上,我得到了(不期望的)

的输出
--------------8d325d822338686
Content-Disposition: form-data; name="file"; filename="file.json"
Content-Type: application/octet-stream

{
  {JSON DATA}
}
--------------8d325d822338686--

如果页面上没有包含所有详细信息,我将如何上传文件?

要上传的文件不包含预期的上传详细信息 - 只是说明一下。

@MaximilianGerhardt 建议 post 我的回答

FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://domain.com/outputlocationfile.json");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("username", "password");
StreamReader sourceStream = new StreamReader("localfile.json");
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();

https://msdn.microsoft.com/en-us/library/ms229715(v=vs.110).aspx