I'm using Indy to build both a client and server application using HTTP. On the Client, I'm using TIdHTTP and on the server I'm using TIdHTTPWebBrokerBridge with a web module. I need the Client to be able to post any type of data via a Stream to the Server. This is done through a universal command I have called /set?Key=API_KEY&Name=FILE_NAME where Key is the API Key for authentication and Name is the name of the file being posted.
On the client, I am posting the data like so:
function TInnoCloudClient.SetData(const Name: String; AStream: TStream): Bool;
var
U: String;
begin
U:= FServerURL; //Base URL of Server
if Copy(U, Length(U)-1, 1) <> '/' then
U:= U + '/';
U:= U + 'get?Key='+Encode(FAPIKey);
U:= U + '&Name='+Encode(Name);
try
FWeb.Post(U, AStream);
except
on e: exception do begin
//Handle Exception
end;
end;
end;
This function is supposed to save the data inside AStream to a file on the server with the filename of Name. On the Server end, however, in the request handler, I see no corresponding TStream property in the Request which I can read this from.
In the Server, how do I acquire the data which I sent as a TStream descendant? I don't need to know how to save it or handle the request, just how do I obtain this Stream from the Request (TWebRequest)?