Sample code for 30+ languages & platforms
Perl

Example: Http.S3_FileExists method

Demonstrates the S3_FileExists method.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $http = Chilkat2::Http->new;

# Insert your AWS keys here:
$http->AwsAccessKey('AWS_ACCESS_KEY');
$http->AwsSecretKey('AWS_SECRET_KEY');

my $bucketName = 'chilkat.ocean';
my $objectName = 'seahorse.jpg';
$http->AwsRegion('us-west-2');
$http->AwsEndpoint('s3-us-west-2.amazonaws.com');

my $retval = $http->S3_FileExists($bucketName, $objectName);
if ($retval < 0) {
    print "Failed to check for the S3 object existence\n";
    print $http->LastErrorText, "\n";
    exit;
}

if ($retval == 0) {
    print "The S3 object does not exist.\n";
    exit;
}

print "The S3 object exists.\n";