From 296b8bc80d3d4f77b94d7fab480df3ecfd407063 Mon Sep 17 00:00:00 2001 From: Vinicius Sanchez Date: Wed, 27 Nov 2024 11:05:15 -0300 Subject: [PATCH] Bug fix: Alexandre Magno --- src/RESTRequest4D.Request.FPHTTPClient.pas | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/RESTRequest4D.Request.FPHTTPClient.pas b/src/RESTRequest4D.Request.FPHTTPClient.pas index 3cc1b97..84e78b8 100644 --- a/src/RESTRequest4D.Request.FPHTTPClient.pas +++ b/src/RESTRequest4D.Request.FPHTTPClient.pas @@ -535,6 +535,7 @@ function TRequestFPHTTPClient.AddFile(const AFieldName: string; const AFileName: function TRequestFPHTTPClient.AddFile(const AFieldName: string; const AValue: TStream; const AFileName: string; const AContentType: string): IRequest; var LFile: TFile; + LFileName: string; begin Result := Self; if not Assigned(AValue) then @@ -543,7 +544,11 @@ function TRequestFPHTTPClient.AddFile(const AFieldName: string; const AValue: TS begin if not FFiles.ContainsKey(AFieldName) then begin - LFile := TFile.Create(AValue, AFileName, AContentType); + LFileName := AFileName; + if LFileName.Trim.IsEmpty then + LFileName := AFieldName; + + LFile := TFile.Create(AValue, LFileName, AContentType); FFiles.AddOrSetValue(AFieldName, LFile); end; end;