diff --git a/Classes/Driver/AmazonS3Driver.php b/Classes/Driver/AmazonS3Driver.php
index dd64c757..0fa35790 100644
--- a/Classes/Driver/AmazonS3Driver.php
+++ b/Classes/Driver/AmazonS3Driver.php
@@ -226,7 +226,8 @@ public function processConfiguration()
*/
public function initialize()
{
- $this->initializeBaseUrl()
+ $this->loadSettings()
+ ->initializeBaseUrl()
->initializeBaseFolder()
->initializeSettings()
->initializeClient();
@@ -1060,6 +1061,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
*
@@ -1113,16 +1140,13 @@ protected function initializeBaseFolder(): self
*/
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;
}