Title: TRTCDataRequest ResponseDone event Post by: dpcroghan on December 19, 2013, 11:17:38 PM Hi Danijel,
At the end of a successful post to the server I'd like to delete the local file if the status is 200. Before the post I set the TRTCDataRequest drPutFile.Request.Info.asText['file'] to the path to the local file to upload. However, trying to read this property in the ResponseDone event of the TRTCDataRequest returns an empty string. I'm trying to avoid using a private global variable to hold the local file name and path, is there any other way. I don't fully understand the RTC class framework yet, so maybe I'm missing something. Thanks, dp procedure TForm1.drPutFileResponseDone(Sender: TRtcConnection); var rdsClient : TRtcDataClient absolute Sender; begin pb1.Position := 0; // if status of put good, do we want to delete local file at this point? if (rdsClient.Response.StatusCode = 200) then begin mmResult.Lines.Add('File was uploaded.'); mmResult.Lines.Add('Deleting the local file unless it has to be sent to other locations.'); // if not some flag not to delete then mmResult.Lines.Add('File to delete: ' + drPutFile.Request.Info.asText['file']); // <-- empty string end else begin mmResult.Lines.Add('File was not uploaded successfully.'); mmResult.Lines.Add('Status: ' + IntToStr(rdsClient.Response.StatusCode) + rdsClient.Response.StatusText); end; end; Title: Re: TRTCDataRequest ResponseDone event Post by: D.Tkalcec (RTC) on December 19, 2013, 11:32:59 PM The complete "Request" object is moved from the "TRtcDataRequest" component to the connection component when you call the "Post" method. First, it will be placed into the request queue, then (when the request starts being processed and one of the RTC events is called), it will be available through the "Request" property of the connection component. In short, you can access the "Request" object the same way you are already accessing the "Response" object, through the TRtcDataClient(Sender) parameter passed to the RTC event.
procedure TForm1.drPutFileResponseDone(Sender: TRtcConnection); var rdsClient: TRtcDataClient absolute Sender; begin pb1.Position := 0; // if status of put good, do we want to delete local file at this point? if (rdsClient.Response.StatusCode = 200) then begin mmResult.Lines.Add('File was uploaded.'); mmResult.Lines.Add('Deleting the local file unless it has to be sent to other locations.'); // if not some flag not to delete then mmResult.Lines.Add('File to delete: ' + rdsClient.Request.Info.asText['file']); // <-- change here end else begin mmResult.Lines.Add('File was not uploaded successfully.'); mmResult.Lines.Add('Status: ' + IntToStr(rdsClient.Response.StatusCode) + rdsClient.Response.StatusText); end; end; Best Regards, Danijel Tkalcec Title: Re: TRTCDataRequest ResponseDone event Post by: dpcroghan on December 20, 2013, 03:54:34 PM Thank you Danijel for a speedy reply.
Happy Holidays |