Title


I tried to take a binary file from the field table,
then I send it in the form of JSON, binary load successful in no kencala, but the result of a binary form of a .pdf file, size 0KB
is there anything wrong, I use methods DataSnap
any One Can Help Me...
thanks...


-----------
Server Side

function TServerMethods1.CobaLoad(NoHp, Dvs, KdPro, Subpro, JnsLap, Per1, Per2,
Status: String; Tanggal:String; Status2: String): TFDJSONDataSets;
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select Laporan from Tugas where UserId='''+NoHP+''' and Divisi='''+Dvs+''' and KodePro='''+KdPro+''' and SubPro='''+SubPro+''' and Jenis='''+JnsLap+''' And Status2=''2'' ');
Query1.Open();

Result:=TFDJSONDataSets.Create;
TFDJSONDataSetsWriter.ListAdd(Result, Query1);
end;


-----------
Client Side

Var NoHp,Dvs,KdPro,SubPro,JnsLap,Per1,Per2,Status,Tanggal,Status2:String;
BS: TBlobStream; FS: TFileStream;
Intent: JIntent;
idMimeTable: TIdMimeTable;
TmpStream:TStream;

RestClient:TFDJSONDatasets;
begin

NoHp:='866225022262113'; Dvs:='11'; KdPro:='001';
SubPro:='Induk Trading Feed'; JnsLap:='Neraca';
Per1:='1635'; Per2:='1639'; Status:='0'; Tanggal:='27/10/2016, 14.45'; Status2:='2';

ClientRest:=TServerMethods1Client.Create(ClientModule1.DSRestConnection1);

RestClient:=ClientRest.CobaLoad(NoHp,Dvs,KdPro,SubPro,JnsLap,Per1,Per2,Status,Tanggal,Status2);

Assert(TFDJSONDataSetsReader.GetListCount(RestClient)=1);

FDMemTable1.Close;
FDMemTable1.AppendData(TFDJSONDataSetsReader.GetListValue(RestClient,0));
FDMemTable1.First;

NamaFile:=NoHP+'_'+Dvs+'_'+KdPro+'_'+SubPro+'_'+JnsLap+'.pdf';
Lokasi:=TPath.Combine(TPath.GetDownloadsPath,NamaFile);
if Not FDMemTable1.IsEmpty then
begin
try
TmpStream:= FDMemTable1.CreateBlobStream(FDMemTable1.FieldByName('Laporan'), bmRead);
TmpStream.Seek(0, soFromBeginning);
FS:= TFileStream.Create(Lokasi, fmCreate or fmShareDenyWrite);
try TmpStream.CopyFrom(FS, FS.Size)
finally FS.Free end;
finally TmpStream.Free end;

OpenFile(Lokasi,True);
end;

Comments

  1. There is no such version. It is Delphi 10 Seattle. The previous version was Delphi XE8, then subsequent is Delphi 10.1 Berlin.

    ReplyDelete
  2. sapta dwi Husein If you post on SO, post a link to the SO question here, instead of cross posting the whole question. If SO deletes your question, then feel free to post here :P

    ReplyDelete

Post a Comment