PHP code example of eben-hk / amazon-s3-php-namespace

1. Go to this page and download the library: Download eben-hk/amazon-s3-php-namespace library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eben-hk / amazon-s3-php-namespace example snippets


$s3 = new S3($awsAccessKey, $awsSecretKey);

S3::setAuth($awsAccessKey, $awsSecretKey);

S3::putObject(S3::inputFile($file, false), $bucketName, $uploadName, S3::ACL_PUBLIC_READ)

S3::putObject($string, $bucketName, $uploadName, S3::ACL_PUBLIC_READ, array(), array('Content-Type' => 'text/plain'))

S3::putObject(S3::inputResource(fopen($file, 'rb'), filesize($file)), $bucketName, $uploadName, S3::ACL_PUBLIC_READ)

S3::getObject($bucketName, $uploadName)

S3::getObject($bucketName, $uploadName, $saveName)

S3::getObject($bucketName, $uploadName, fopen('savefile.txt', 'wb'))

S3::copyObject($srcBucket, $srcName, $bucketName, $saveName, $metaHeaders = array(), $requestHeaders = array())

S3::deleteObject($bucketName, $uploadName)

S3::listBuckets()  // Simple bucket list
S3::listBuckets(true)  // Detailed bucket list

S3::putBucket($bucketName)

S3::getBucket($bucketName)

S3::deleteBucket($bucketName)