PHP code example of devtoolboxuk / aws

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

    

devtoolboxuk / aws example snippets




$this->aws = new aws();

$this->s3 = $this->aws->s3();

$this->s3->setBucket('test-bucket');

$list = $this->s3->listObjects('folder');
foreach ($list as $object) {
    print_r($object['Key']);
}

$this->s3->getObject($localFilename, $s3filename)

$awsS3 = $this->aws->s3();
$awsS3->setBucket('test-bucket');
$streamWrapper = $awsS3->getStreamWrapper()

$awsS3 = $this->aws->s3();
$awsS3->setBucket('test-bucket');

$objectName = 'folder/folder/file.xml';
$chunkCount =  $awsS3->countDownloadStreamChunks($objectName);

echo sprintf(
    "\nUsing a stream, there were %d chunks\n",
    $chunkCount
);

// Opens the file for Streaming
$awsS3->openDownloadStream($objectName);

//outputs the streamed data
for($i=0;$i<$chunkCount;$i++) {
    echo $awsS3->getDownloadStream($i);
}

// Closes the streamed file
$awsS3->closeDownloadStream();

sh
$ php -r "readfile('https://getcomposer.org/installer');" | php
sh
$ php composer.phar install