This is a driver for the file abstraction layer (FAL) to support Amazon AWS S3.
You can create a file storage which allows you to upload/download and link the files to an AWS S3 bucket. It also supports the TYPO3 CMS image rendering.
Requires TYPO3 11.5 - 12.4
Issue tracking: GitHub: AWS S3 FAL Driver
Packagist: andersundsehr/aus-driver-amazon-s3
Composer installation:
composer require andersundsehr/aus-driver-amazon-s3
Add the following configurations:
Make sure that your AWS S3 bucket is accessible to public web users.
For example add the following default permissions to “Edit bucket policy”:
Example permissions:
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucketname/*"
}
]
}
Edit in “Extension Manager” the following extension settings:
ausdriveramazons3_metainfocache
retains metadata from AWS S3 on a per-object basis. ausdriveramazons3_requestcache
stores the complete response of a specific request, facilitating efficient data access and performance enhancement.By default, these caches are transient. However, if you choose to configure a persistent cache backend, it's crucial to remember that such a cache will not automatically recognize changes from the data source. In this case, it becomes your responsibility to implement the necessary updates manually.
Detailed instructions on how to customize these cache backends can be found in the TYPO3 CachingFramework Configuration Guide. Remember, thorough testing is essential when modifying cache backends.
Example with simple file backend; all changes through TYPO3
[
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
'backend' => \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::class,
'groups' => [
'pages'
],
];
Example with redis
[
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
'backend' => \TYPO3\CMS\Core\Cache\Backend\RedisBackend::class,
'options' => [
'defaultLifetime' => 0, // infinite
'database' => 0,
'hostname' => 'redis',
'port' => 6379,
],
];
If you use your own Amazon AWS SDK, you may want to work with your own S3 client object.
So you have to use the following hook in your own ext_loaclconf.php:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aus_driver_amazon_s3']['initializeClient-preProcessing'][] = \Vendor\ExtensionName\Hooks\AmazonS3DriverHook::class . '->initializeClient';
A hook class might look like this:
namespace Vendor\ExtensionName\Hooks;
class AmazonS3DriverHook {
public function initializeClient(array &$params, $obj){
$params['s3Client'] = MyAwsFactory::getAwsS3Client($params['configuration']);
}
}
You can set the public base URL in the configuration of your driver (TYPO3 backend). But maybe you want to set this on an other place.
So you have to use the following hook in your own ext_loaclconf.php:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aus_driver_amazon_s3']['initializeBaseUrl-postProcessing'][] = \Vendor\ExtensionName\Hooks\AmazonS3DriverHook::class . '->initializeBaseUrl';
A hook class might look like this:
namespace Vendor\ExtensionName\Hooks;
class AmazonS3DriverHook {
public function initializeBaseUrl(array &$params, $obj){
$params['baseUrl'] = 'https://example.com';
}
}
There is a default setting to set the cache control header's max age for all file types. If you want to use special cache headers, you can use this hook:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aus_driver_amazon_s3']['getCacheControl'][] = 'Vendor\ExtensionName\Hooks\AmazonS3DriverHook->getCacheControl';
You can modify the parameter "cacheControl" as you wish. Please Notice: AWS S3 set the cache header only once - while uploading / creating or copy the file.
If you wish other hooks - don’t be shy: GitHub issue tracking: Amazon S3 FAL Driver