5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS SDK for PHPで署名付きURLを生成する小さなサンプル

Last updated at Posted at 2016-05-03

前提/環境

#手順
1.S3に任意オブジェクトをアップロードしておく(バケット名、オブジェクト名を覚えておく)
手順省略

2.AWS SDK for PHPのインストール

# composer require aws/aws-sdk-php

3.署名付きURLの生成(スクリプト作成)

スクリプト作成

test.php
<?php
require 'vendor/autoload.php';

$s3 = new Aws\S3\S3Client([
    'version' => 'latest',
    'region'  => 'ap-northeast-1'
]);

$command = $s3->getCommand('GetObject', array(
        'Bucket' => '<Bucket Name>',
        'Key' => '<Object Name>',
));

$request = $s3->createPresignedRequest($command, '+1 minutes');
echo (string)$request->getUri();

実行

# php test.php
5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?