I have need to send files to a Delphi service. I am able to send the files, but have not figured out how to extract the multipart items when received.
procedure TForm15.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
ARequestInfo.PostStream.Seek(0, soFromBeginning);
Memo1.Lines.LoadFromStream(ARequestInfo.PostStream);
end;
Here is what I get when file is posted with a 2 other values added to the stream. What I need is a way to access each item.
How do I ask for "type" and get back "OPRS"
How do I ask for "ID" and get back "1234"
How do I ask for "filename" and get back "test.pdf"
How do I ask for actual file contents and save to memory stream to then write to disk
----------040224182640701
Content-Disposition: form-data; name="type"
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
OPRS
----------040224182640701
Content-Disposition: form-data; name="ID"
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
1234
----------040224182640701
Content-Disposition: form-data; name="file"; filename="test.PDF"
Content-Type: application/pdf
Content-Transfer-Encoding: binary
%PDF-1.6
%âãÏÓ
290 0 obj
<<
/Border [ 0 0 0 ]
/Contents (þÿ