(PHP ActiveX) Generate S3 Signed URL
Demonstrates how to generate a pre-signed S3 URL.
<?php
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Http')
$http = new COM("Chilkat.Http");
// Insert your access key here:
$http->AwsAccessKey = 'AWS_ACCESS_KEY';
// Insert your secret key here:
$http->AwsSecretKey = 'AWS_SECRET_KEY';
$bucketName = 'chilkattest';
$path = 'starfish.jpg';
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.CkDateTime')
$expireTime = new COM("Chilkat.CkDateTime");
$expireTime->SetFromCurrentSystemTime();
$expireTime->AddSeconds(3600);
$signedUrl = $http->s3_GenerateUrl($bucketName,$path,$expireTime);
if ($http->LastMethodSuccess != 1) {
print $http->LastErrorText . "\n";
}
else {
print $signedUrl . "\n";
}
?>
|