PHP code example of gixx / worstpractice-aws-s3-adapter
1. Go to this page and download the library: Download gixx/worstpractice-aws-s3-adapter 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/ */
gixx / worstpractice-aws-s3-adapter example snippets
defined('S3_ACCESS_KEY') || define('S3_ACCESS_KEY', '<MyAccessKey>');
defined('S3_SECRET_KEY') || define('S3_SECRET_KEY', '<MySecretKey>');
EY,
S3_SECRET_KEY
);
$s3Client = new S3Client([
'credentials' => $credentials,
'region' => 'eu-central-1',
'version' => '2006-03-01',
]);
$s3Adapter = new Adapter($s3Client);
$s3Adapter->setBucket('my-bucket');
// The result will be the "key" (kind of absolute path + filename) of the file in the S3 bucket or NULL when no file
// found on the given "path".
$latestFileInFolder = $s3Adapter->getLastUploadedKeyByPrefix('folder/subfolder');