AWS SDK for PHP で S3 ファイル取得(2)

なるほど。では。

<?php

require_once('AWSSDKforPHP/aws.phar'); // PEAR
use Aws\S3\S3Client;

$client = S3Client::factory(array('key'    => getenv('AWS_KEY'),
                                  'secret' => getenv('AWS_SECRET')));
$client->registerStreamWrapper();
  • bitmap_comp.php
    if (strncmp($file, 's3://', 5) === 0) {
        require_once('S3_Wrapper.php');
    }
    $data = file_get_contents($file);

使い方は前のと同じ。