function:
procedure TMultiPartFormData.AddFieldContent(Field: TRttiField; var Content: TStringList);
const
FmtTextContent = 'Content-Disposition: form-data; name="%s"'+ sLineBreak+sLineBreak +'%s';
FmtFileContent = 'Content-Disposition: form-data; name="%s"; filename="%s"'+ sLineBreak +'Content-Type: %s'+ sLineBreak+sLineBreak+ '%s';
var
Attachment: TMultiPartFormAttachment;
begin
if Field.FieldType.TypeKind in [tkString, tkUString, tkWChar, tkLString, tkWString, tkInteger, tkChar, tkWChar] then
begin
Content.Add(Format(FmtTextContent, [Field.Name, Field.GetValue(Self).AsString]));
Exit;
end;
if Field.FieldType.Name.Equals(TMultiPartFormAttachment.ClassName) then =>Error Here
begin
Attachment := Field.GetValue(Self).AsType;
Content.Add(Format(FmtFileContent, [Field.Name, Attachment.FileName, Attachment.MimeType, Attachment.Content.DataString]));
end;
end;
[DCC Error] RestClient.pas(1076): E2018 Record, object or class type required
compiling packages Delphi xe2 error
function: procedure TMultiPartFormData.AddFieldContent(Field: TRttiField; var Content: TStringList); const FmtTextContent = 'Content-Disposition: form-data; name="%s"'+ sLineBreak+sLineBreak +'%s'; FmtFileContent = 'Content-Disposition: form-data; name="%s"; filename="%s"'+ sLineBreak +'Content-Type: %s'+ sLineBreak+sLineBreak+ '%s'; var Attachment: TMultiPartFormAttachment; begin if Field.FieldType.TypeKind in [tkString, tkUString, tkWChar, tkLString, tkWString, tkInteger, tkChar, tkWChar] then begin Content.Add(Format(FmtTextContent, [Field.Name, Field.GetValue(Self).AsString])); Exit; end;
if Field.FieldType.Name.Equals(TMultiPartFormAttachment.ClassName) then =>Error Here begin Attachment := Field.GetValue(Self).AsType;
Content.Add(Format(FmtFileContent, [Field.Name, Attachment.FileName, Attachment.MimeType, Attachment.Content.DataString]));
end;
end;
[DCC Error] RestClient.pas(1076): E2018 Record, object or class type required