Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Yousign: Download File
See more Yousign Examples
Downloads a previously uploaded Yousign file.Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Http;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
http: THttp;
downloadUrl: string;
localFilePath: string;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := THttp.Create;
// Adds the "Authorization: Bearer YOUR_API_KEY" header.
http.AuthToken := 'YOUR_API_KEY';
downloadUrl := 'https://staging-api.yousign.com/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/download?alt=media';
localFilePath := 'qa_output/x.pdf';
success := http.Download(downloadUrl,localFilePath);
if (success = False) then
begin
WriteLn(http.LastErrorText);
Exit;
end;
WriteLn('The PDF file is downloaded...');
http.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.