Reputation: 323
I have recently started using DataSnap in Delphi to produce what will be a RESTful web service. After following guides by the man himself Marco Cantu and several others on the internet I have successfully got the whole 'chain' working.
But there is a small issue of speed; the client can now send a stream (along with it's size) to the server (which, because of the bug here DataSnap XE2 and TStream method parameters, is read upto the sent size), and the server will reassemble it into a file and save it on disk.
But foir a 3.66MiB file, this takes over 50 seconds!
Should this be the case? On the server I have:
try
F := TFileStream.Create('written.dat', fmCreate);
F.Position := 0;
F.CopyFrom(Data, DataSize);
finally
F.Free;
And on the client end:
var
Server: TServerMethods1Client;
DBStream: TFileStream;
begin
Server := TServerMethods1Client.Create(SQLConnection1.DBXConnection);
try
DBStream := TFileStream.Create('DataSnapServer.exe', fmOpenRead);
DBStream.Position := 0;
Showmessage(IntToStr(Server.SendData(DBStream, DBStream.Size)));
finally
Server.Free;
Any help appreciated!
Cheers, Adrian
Upvotes: 3
Views: 2225
Reputation: 11
On server side, try adjusting BufferKBSize
property on TDSHTTPWebDispatcher
component. Same property can be found on TsqlConnection
component on client.
Upvotes: 1