(PHP Extension) Generate S3 Signed URL
Demonstrates how to generate a pre-signed S3 URL.
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$http = new CkHttp();
// Insert your access key here:
$http->put_AwsAccessKey('AWS_ACCESS_KEY');
// Insert your secret key here:
$http->put_AwsSecretKey('AWS_SECRET_KEY');
$bucketName = 'chilkattest';
$path = 'starfish.jpg';
$expireTime = new CkDateTime();
$expireTime->SetFromCurrentSystemTime();
$expireTime->AddSeconds(3600);
$signedUrl = $http->s3_GenerateUrl($bucketName,$path,$expireTime);
if ($http->get_LastMethodSuccess() != true) {
print $http->lastErrorText() . "\n";
}
else {
print $signedUrl . "\n";
}
?>
|