Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AWS SDK PHP v3を利用した署名付きURLの取得方法
require 'vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
try {
$s3Client = S3Client::factory([
'version' => 'latest',
'region' => 'ap-northeast-1',
'credentials' => array(
'key' => getenv('AWS_ACCESS_KEY_ID'),
'secret' => getenv('AWS_SECRET_KEY'),
$cmd = $s3Client->getCommand('GetObject', [
'Bucket' => 'BucketName',
'Key' => 'path/to/fileName.png',
'ResponseContentDisposition' => 'downloadFileName.png'
$request = $s3Client->createPresignedRequest($cmd, '+10 minutes');
$url = (string) $request->getUri();
echo $url;
} catch (S3Exception $e) {
echo $e->getMessage() . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.