danieleteti/delphimvcframework

File upload Problem with Encoding

ads69 opened this issue · 3 comments

ads69 commented

Hi,
I have made something based on the file Upload sample and no problem when uploading binary files like pictures.
When I try to upload a specific pdf file I get this error :

No mapping for the Unicode character exists in the target multi-byte code page>

the code I use is the same
lFile := TFile.Create(lFName); lFile.CopyFrom(Context.Request.Files[0].Stream, 0);
Any idea ?

Best regards

Did you try to use the sample with that pdf file? I cannot reproduce the error.

ads69 commented

Hi Daniele,
You're right the in the sample it works but I use the swagger in my side.
using this parameter
[MVCSwagParam(plFormData, 'file', 'File to upload', ptFile, False)]
Best regards

ads69 commented

Daniele,
I have finally found where the problem is and reproduced it with the sample.
I use the MiddleWare Trace (MVCFramework,MVCFramework.Middleware.Trace).
If I do
MVC.AddMiddleware(TMVCTraceMiddleware.Create);

The problem occurs here :

 lContentStream.WriteString(EncodingGetString(Context.Request.Headers['content-type'],
      Context.Request.RawWebRequest.RawContent));

Best regards

Armindo