0

I am using dropzone.js to upload files to Web API 2 service. Reading multipart stream gives garbled Russian characters. For example, when I upload file with name Русское название - Russian characters it gives ????? ?????? - Russian characters.

I'm sure that dropzone.js works fine and it is just a Web API problem.

Here is GetStream method.

public override Stream GetStream(HttpContent parent, HttpContentHeaders headers)
        {
            // For form data, Content-Disposition header is a requirement
            ContentDispositionHeaderValue contentDisposition = headers.ContentDisposition;
            if (contentDisposition != null)
            {
                // We will post process this as form data
                _isFormData.Add(String.IsNullOrEmpty(contentDisposition.FileName));

                return new MemoryStream();
            }

            // If no Content-Disposition header was present.
            throw new InvalidOperationException(
                string.Format("Did not find required '{0}' header field in MIME multipart body part..",
                              "Content-Disposition"));
        }
Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
Nickita Fabregas
  • 319
  • 1
  • 3
  • 13
  • This has nothing to do with Classic ASP. ASP.NET and Classic ASP are two different technologies. – Paul Mar 09 '15 at 11:47

1 Answers1

0

It is probably bad encoding on js side imo. As you have posted instead of "Русское название - Russian characters" you get "????? ?????? - Russian characters", which means that file is readen with suport of English characters but without russian ones. Try changing encoding to one that supports cyrylic characters. This might be helpfull: http://en.wikipedia.org/wiki/Character_encoding.

Offa
  • 111
  • 10
  • I'm sure the problem is in server side. Thanks for the reply. – Nickita Fabregas Mar 10 '15 at 08:41
  • It's still encoding error IMO, however it might be on the server side. I had a simillar situation with reading and writing stream from CSV with polish characters included. C# string is encoded with UTF-16, first encoding you are encountering is in JS, then there might be second on server while reading stream from client and third if you are saving stream to file(I don't know your code, but there should be at least to of above cases). Check If in all cases you are using proper coding for cyrylic, because one usage of wrong encoding will ruin the data. – Offa Mar 11 '15 at 06:20
  • Also check this: http://stackoverflow.com/questions/22552490/jsp-giving-page-with-question-marks-for-russian-text – Offa Mar 11 '15 at 06:36