RTC Forums
November 24, 2024, 03:58:36 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Login
Register
RTC Forums
>
Subscription
>
Support
>
TRTCDataRequest ResponseDone event
Pages: [
1
]
« previous
next »
Print
Author
Topic: TRTCDataRequest ResponseDone event (Read 4297 times)
dpcroghan
RTC Expired
Posts: 17
TRTCDataRequest ResponseDone event
«
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;
Logged
D.Tkalcec (RTC)
Administrator
Posts: 1881
Re: TRTCDataRequest ResponseDone event
«
Reply #1 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
Logged
dpcroghan
RTC Expired
Posts: 17
Re: TRTCDataRequest ResponseDone event
«
Reply #2 on:
December 20, 2013, 03:54:34 PM »
Thank you Danijel for a speedy reply.
Happy Holidays
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Dashboard
-----------------------------
=> General
=> 3rd-Party
=> Quick Start
-----------------------------
Subscription
-----------------------------
=> Support
Loading...