Presigned URL for AWS S3 Object with PHP

This is a tutorial on how to generate a presigned url for Amazon AWS S3 Object with PHP.

This is a short tutorial on how to create a presigned url for an amazon S3 object.


use Aws\S3\S3Client;

$bucket = 'mybucketname';

$s3 = S3Client::factory(array(
    'region'  => 'us-west-2',
    'version' => 'latest',
    'credentials' => [
        'key'    => 'AWS_KEY',
        'secret' => 'AWS_SECRET'

$cmd = $s3->getCommand('GetObject', [
    'Bucket' => $bucket,
    'Key'    => $file_key

$request = $s3->createPresignedRequest($cmd, '+20 minutes');

// Get the actual presigned-url
$presignedUrl = (string) $request->getUri();


Full Documentation: