This class is a standalone Amazon S3 REST implementation for PHP 5.2.x (using CURL), that supports large file uploads and doesn't require PEAR.

Download source:

Example usage (also see example.php and the class documentation):

                      $s3 = new S3('accessKey', 'secretKey');
$s3->putBucket('bucket', S3::ACL_PUBLIC_READ);
$s3->putObjectFile('file.doc', 'bucket', 'docs/file.doc', S3::ACL_PUBLIC_READ);
$s3->deleteObject('bucket', 'docs/file.doc');

Writing and reading resources:

                      # Upload an object from a resource (requires bytesize):
$s3->putObject($s3->inputResource(fopen($file, 'rb'), filesize($file)), $bucketName, $uploadName, S3::ACL_PUBLIC_READ);
# Download an object to a resource:
$s3->getObject($bucketName, $uploadName, fopen($savefile, 'wb'));

Known Issues:

  • Files larger than 2GB are not supported on 32 bit systems due to PHP's signed integer problem
  • SSL is enabled by default and can cause problems with large files. If you don't need SSL, disable it with S3::$useSSL = false;

More Information:

Changelog

  • 0.4.0 (2009-07-20):
    Updates to copyObject, new getHttpUploadPostParams method for form uploads and fixes for 0 byte PUTs
  • 0.3.8 (2008-12-16):
    Support for spaces and special characters in URIs
  • 0.3.7 (2008-11-27):
    Support for CloudFront and changes to setBucketLogging()
  • 0.3.6 (2008-10-23):
    PHPDoc comment updates
  • 0.3.5 (2008-10-08):
    Added getAuthenticatedURL() and an ACL parameter to copyObject()
  • 0.3.4 (2008-09-11):
    Small updates and support for 0 byte data
  • 0.3.3 (2008-07-30):
    Fixed minor getBucket() bugs, added delimiter
  • 0.3.2 (2008-07-12):
    Fixed ?logging bug and changed putObject() to accept request headers (thanks to Angelo Mandato for providing details)
  • 0.3.1 (2008-06-20):
    Added copyObject() and updated README.txt
  • 0.2.9 (2008-06-20):
    Added getBucketLocation() and a location parameter to putBucket() for EU buckets
  • 0.2.8 (2008-06-06):
    Added sort() for AMZ meta headers (thanks Malone)
  • 0.2.7 (2008-05-30):
    Commented out uncommented var_dump() (thanks Chris)
  • 0.2.6 (2008-05-29):
    Replaced isset() with array_key_exists() since isset() was ignoring null parameters (thanks Joe)
  • 0.2.5 (2008-05-29):
    Added support for ?location and ?torrent parameters (thanks Joe)
  • 0.2.4 (2008-05-27):
    Fix for ?prefix bug (thanks Lucas)
  • 0.2.3 (2008-05-04):
    Small bug fixes, updated examples and comments, moved source to SVN
  • 0.2.2 (2008-05-02):
    Added S3 wrapper example
  • 0.2.1 (2008-04-28):
    First 0.2 beta (0.1 development discontinued)

Amazon S3™ is a trademark of Amazon.com, Inc. or its affiliates.