danieleteti / delphimvcframework

DMVCFramework (for short) is a popular and powerful framework for WEB API in Delphi. Supports RESTful and JSON-RPC WEB APIs development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

File upload Problem with Encoding

ads69 opened this issue · comments

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.

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

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