alistairphillips.com

I’m : a web and mobile developer based in the Manning Valley, Australia.


Amazon S3 (Simple Storage Service)

Discovered yesterday that the Zend Framework makes it dead easy to access Amazon S3.

<?php

    set_include_path( PATH_SEPARATOR . '/Downloads/zf/library/');

    require_once 'Zend/Service/Amazon/S3.php';

    $s3 = new Zend_Service_Amazon_S3($id, $key);

    // Upload ourselves
    $s3->putFile( "s3.php", "bucket_id/s3.php");

    $list = $s3->getBuckets();
    foreach($list as $bucket) {
      echo "I have bucket $bucket\n";
      $test = $s3->getObjectsByBucket( $bucket );
      print_r( $test );
    }
?>

But if you're not using the Zend Framework then you might want to check out Amazon S3 PHP Class.