PHP code example of mafordham / aws-s3

1. Go to this page and download the library: Download mafordham/aws-s3 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/ */

    

mafordham / aws-s3 example snippets




Or use Composer autoloading by adding the src/ directory to your composer.json:

{
  "autoload": {
    "psr-4": {
      "MaFordham\\AwsS3\\": "src/"
    }
  }
}

use YourNamespace\\AwsS3\\AwsS3;

$s3 = new AwsS3([
    'access_key' => 'YOUR_AWS_ACCESS_KEY',
    'secret_key' => 'YOUR_AWS_SECRET_KEY',
    'region'     => 'us-east-1',
]);

$objects = $s3->objectsList();
print_r($objects);

$s3->objectPut('my-bucket', '/remote/path/file.txt', 'image/png', base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO/tO7sAAAAASUVORK5CYII='));

$s3->objectGet('my-bucket', '/remote/path/file.txt');

$s3->objectDelete('my-bucket', '/remote/path/file.txt');

$s3->objectUrl('my-bucket', '/remote/path/file.txt');
bash
composer dump-autoload