procedure TfrmEngineerImport.btnDownloadClick(Sender: TObject);
var vsql, SourceFile, DestFile, filename, filepath: string; DownLoadFile: TFileStream; vUniqry: TUniQuery;begin vSql := 'SELECT a.attachment_name,a.attachment_url FROM qo_order t inner join qo_order_schedule os on os.qo_order_id=t.id ' + ' inner join qo_order_sch_process p on p.qo_order_schedule_id=os.id ' + ' inner join qo_order_sch_process_atta a on a.qo_order_sch_process_id=p.id ' + 'where t.wc_contract_id=413'; ServiceDataModule.GetUniQry(vUniqry); ServiceDataModule.OpenUniQueryBySQL(vUniqry, vSql); with vUniqry do begin First; while not Eof do begin filepath := fieldbyname('attachment_url').AsString; filename := fieldbyname('attachment_name').AsString; SourceFile := 'http://127.0.0.1:8080/' + filepath + '/' + filename; DestFile := 'c:\img\'+filename;{ if DownloadFile(AnsiToUtf8(SourceFile), DestFile) then
begin mmoLog.Lines.Add(filename + ':Download succesful!') end else begin mmoLog.Lines.Add(SourceFile) end; } DownLoadFile := TFileStream.Create(DestFile, fmCreate); IdHTTP1.Get(AnsiToUtf8(SourceFile), DownLoadFile); DownLoadFile.Free; Next; end; end;ServiceDataModule.CloseUniQry(vUniqry);
end;