PHP code example of sters / cakephp3-aws-s3-datasource
1. Go to this page and download the library: Download sters/cakephp3-aws-s3-datasource 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/ */
sters / cakephp3-aws-s3-datasource example snippets
'Datasource' => [
'my_s3_connection' => [
'className' => 'CakeS3\Datasource\Connection',
'key' => 'put your s3 access key',
'secret' => 'put your s3 access secret',
'bucketName' => 'put your bucket name',
'region' => 'put your region',
],
],
class TopController extends Controller
{
public function index()
{
$MyS3Table = TableRegistry::get('MyS3');
$content = $MyS3Table->getObjectBody('/path/to/object/file.jpg');
$this->response->type('image/jpeg');
$this->response->body($content);
return $this->response;
}
}