Hi Both,
Actually delivering timed downloads with S3 is an easy call that can be done with the AWS sdk like this.
// Create a presigned url
$request = $s3Client->createPresignedRequest($s3Client->getCommand('GetObject', [
'Bucket' => 'bucket',
'Key' => 'key'
]), '+5 minutes');
$presignedUrl = (string) $request->getUri();
CloudFront is actually a bit of a pain the called required is like below.
// Create a signed URL for the resource using the canned policy
$signedUrlCannedPolicy = $cloudFront->getSignedUrl([
'url' => $streamHostUrl . '/' . $resourceKey,
'expires' => $expires,
'private_key' => '/path/to/your/cloudfront-private-key.pem',
'key_pair_id' => ''
]);
The difference being you need to add a private_key and key_pair_id then the pem need to be stored somewhere it just creates extra complexities so that’s probably why they don’t offer it the call above just needs two keys from an IAM user.
Some docs: https://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/cloudfront-signed-url.html
Best Regards
Sam
-
This reply was modified 7 years, 8 months ago by
s3bubble.
-
This reply was modified 7 years, 8 months ago by
s3bubble.
-
This reply was modified 7 years, 8 months ago by
s3bubble.
-
This reply was modified 7 years, 8 months ago by
s3bubble.