diff --git a/Classes/Driver/AmazonS3Driver.php b/Classes/Driver/AmazonS3Driver.php
index 4d351a91..31f0bec3 100644
--- a/Classes/Driver/AmazonS3Driver.php
+++ b/Classes/Driver/AmazonS3Driver.php
@@ -218,7 +218,8 @@ public function processConfiguration()
*/
public function initialize()
{
- $this->initializeBaseUrl()
+ $this->loadSettings()
+ ->initializeBaseUrl()
->initializeSettings()
->initializeClient();
$this->resetRequestCache();
@@ -1051,6 +1052,32 @@ public function streamFile(string $identifier, array $properties): ResponseInter
******************** Protected Helpers **********************
*************************************************************/
+ /**
+ * Load extension configuration and load additional storage configuration
+ *
+ * Record-based storage configuration can be overridden by defining
+ * $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['aus_driver_amazon_s3']['storage']
+ * or
+ * $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['aus_driver_amazon_s3']['storage_X']
+ * (where X is the UID of the storage record)
+ * in config/system/additional.php.
+ * This makes it possible to use environment variable based storage configuration.
+ */
+ protected function loadSettings(): self
+ {
+ self::$settings = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::EXTENSION_KEY);
+
+ //allow overriding storage configuration from AdditionalConfiguration.php
+ if (isset(self::$settings['storage'])) {
+ $this->configuration = array_merge($this->configuration, self::$settings['storage']);
+ }
+ if (isset(self::$settings['storage_' . $this->storageUid])) {
+ $this->configuration = array_merge($this->configuration, self::$settings['storage_' . $this->storageUid]);
+ }
+
+ return $this;
+ }
+
/**
* initializeBaseUrl
*
@@ -1091,15 +1118,11 @@ protected function initializeBaseUrl()
*/
protected function initializeSettings()
{
- if (self::$settings === null) {
- self::$settings = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::EXTENSION_KEY);
-
- if (!isset(self::$settings['doNotLoadAmazonLib']) || !self::$settings['doNotLoadAmazonLib']) {
- self::loadExternalClasses();
- }
- if ($this->compatibilityService->isFrontend() && (!isset(self::$settings['dnsPrefetch']) || self::$settings['dnsPrefetch'])) {
- $GLOBALS['TSFE']->additionalHeaderData['ausDriverAmazonS3_dnsPrefetch'] = '';
- }
+ if (!isset(self::$settings['doNotLoadAmazonLib']) || !self::$settings['doNotLoadAmazonLib']) {
+ self::loadExternalClasses();
+ }
+ if ($this->compatibilityService->isFrontend() && (!isset(self::$settings['dnsPrefetch']) || self::$settings['dnsPrefetch'])) {
+ $GLOBALS['TSFE']->additionalHeaderData['ausDriverAmazonS3_dnsPrefetch'] = '';
}
return $this;
}