0

I have a c# client that uploads files to some server. when my client upload a file with Hebrew name, in server it looks as gibberish. I am pretty sure that the problem is in the client side, since this server works with Hebrew characters from other clients. My question is how to set the content header to be enable to send a Hebrew characters.

Here my code:

using (var content = new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture)))
{
    using (FileStream filestream = new FileStream(ti.OutPath, FileMode.Open, FileAccess.Read))
    {
     content.Add(new StreamContent(filestream), "file", "שם עברית.pdf");
     //...
    }
}

I have tried the following:

content.Add(new StreamContent(file), "file", new string(Encoding.GetEncoding("Windows-1255").GetBytes("שם עברית.pdf").Select(b => (char)b).ToArray()));

but same issue

good_shabes
  • 161
  • 7
  • "*RFC 7578. Section 4.2 describes how the 'filename' parameter should be encoded on the wire. Non-ASCII characters should not be directly used; rather, they should be encoded in some manner:*" i guess this is one place where they should be ignoring the specs. Take a look at this https://stackoverflow.com/questions/47004296/httpclient-wrong-encoding-in-content-disposition – TheGeneral Jul 24 '20 at 06:30
  • @TheGeneral I added the lines of code of the accepted answer from tour link, I'm still see in server side this `=?utf-8?B?16fXkdeV16bXldeqLdeR15nXljEueGxzeA==?=` as the file name – good_shabes Jul 24 '20 at 06:49

0 Answers0