Lazarus Pascal
Lazarus Pascal
Example: Http.S3_FileExists method
Demonstrates theS3_FileExists method.
Chilkat Lazarus Pascal 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
http: THttp;
bucketName: string;
objectName: string;
retval: Integer;
begin
http := THttp.Create;
// Insert your AWS keys here:
http.AwsAccessKey := 'AWS_ACCESS_KEY';
http.AwsSecretKey := 'AWS_SECRET_KEY';
bucketName := 'chilkat.ocean';
objectName := 'seahorse.jpg';
http.AwsRegion := 'us-west-2';
http.AwsEndpoint := 's3-us-west-2.amazonaws.com';
retval := http.S3_FileExists(bucketName,objectName);
if (retval < 0) then
begin
WriteLn('Failed to check for the S3 object existence');
WriteLn(http.LastErrorText);
Exit;
end;
if (retval = 0) then
begin
WriteLn('The S3 object does not exist.');
Exit;
end;
WriteLn('The S3 object exists.');
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.