From 27e3a8d18574cc7631e4dd7e16a01c6c36b096f1 Mon Sep 17 00:00:00 2001 From: Julian Weber Date: Mon, 16 Feb 2026 15:08:16 +0100 Subject: [PATCH 1/5] fix: add path style endpoint support --- classes/local/store/s3/client.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index b035fa10..8548834a 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -184,6 +184,10 @@ public function set_client($config) { $options['endpoint'] = $config->s3_base_url; } + if (!empty($config->s3_path_style_endpoint)) { + $options['use_path_style_endpoint'] = $config->s3_path_style_endpoint; + } + $this->client = \Aws\S3\S3Client::factory($options); } From bdf021912fe268c9af15a8c1577a2eddc0b1ec14 Mon Sep 17 00:00:00 2001 From: Julian Weber Date: Mon, 16 Feb 2026 15:10:06 +0100 Subject: [PATCH 2/5] fix: add config option --- classes/local/store/s3/client.php | 7 +++++++ lang/en/tool_objectfs.php | 2 ++ 2 files changed, 9 insertions(+) diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index 8548834a..7fb7ef66 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -517,6 +517,13 @@ public function define_client_section($settings, $config) { '' )); + $settings->add(new \admin_setting_configcheckbox( + 'tool_objectfs/s3_path_style_endpoint', + new \lang_string('settings:aws:path_style_endpoint', 'tool_objectfs'), + new \lang_string('settings:aws:path_style_endpoint_help', 'tool_objectfs'), + 0 + )); + $settings->add(new \admin_setting_configtext( 'tool_objectfs/key_prefix', new \lang_string('settings:aws:key_prefix', 'tool_objectfs'), diff --git a/lang/en/tool_objectfs.php b/lang/en/tool_objectfs.php index 6ee7edbb..6c59bb7f 100644 --- a/lang/en/tool_objectfs.php +++ b/lang/en/tool_objectfs.php @@ -135,6 +135,8 @@ $string['settings:aws:key_help'] = 'Amazon S3 key credential.'; $string['settings:aws:key_prefix'] = 'Prefix to use in bucket'; $string['settings:aws:key_prefix_help'] = 'Prefix to use inside Amazon S3 bucket. Must end with trailing slash when set. Leave blank to use root of bucket.'; +$string['settings:aws:path_style_endpoint'] = 'Path style endpoint'; +$string['settings:aws:path_style_endpoint_help'] = 'Use path style endpoints for S3 client.'; $string['settings:aws:region'] = 'region'; $string['settings:aws:region_help'] = 'Amazon S3 API gateway region.'; $string['settings:aws:sdkcredserror'] = 'Couldn\'t find AWS credentials. It\'s unsafe to enable this setting. Follow up AWS documentation.'; From 7ded98e0089b591d3b39557fc328912891301325 Mon Sep 17 00:00:00 2001 From: Julian Weber Date: Mon, 16 Feb 2026 15:13:41 +0100 Subject: [PATCH 3/5] fix: cast to bool --- classes/local/store/s3/client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index 7fb7ef66..b4458a68 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -185,7 +185,7 @@ public function set_client($config) { } if (!empty($config->s3_path_style_endpoint)) { - $options['use_path_style_endpoint'] = $config->s3_path_style_endpoint; + $options['use_path_style_endpoint'] = (bool) $config->s3_path_style_endpoint; } $this->client = \Aws\S3\S3Client::factory($options); From c2f112f034985e70b55cd8949104d7db2a1ce593 Mon Sep 17 00:00:00 2001 From: Julian Weber Date: Mon, 16 Feb 2026 15:32:11 +0100 Subject: [PATCH 4/5] fix: add missing exception --- classes/local/store/s3/client.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index b4458a68..12f5bc63 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -334,6 +334,9 @@ public function test_connection() { } catch (\Aws\Exception\CredentialsException $e) { $connection->success = false; $connection->details = $this->get_exception_details($e); + } catch (\Aws\Auth\Exception\UnresolvedAuthSchemeException $e) { + $connection->success = false; + $connection->details = $this->get_exception_details($e); } return $connection; From 74a69f015bfe6e565d531fd584bbdebef97b4fdc Mon Sep 17 00:00:00 2001 From: Julian Weber Date: Mon, 16 Feb 2026 17:06:33 +0100 Subject: [PATCH 5/5] fix: 5s timeout on non aws environments --- classes/local/store/s3/client.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index 12f5bc63..3e3ccf40 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -818,6 +818,14 @@ public function define_client_check_sdk($config) { global $OUTPUT; $output = ''; if (empty($config->s3_usesdkcreds)) { + // If AWS_ACCESS_KEY_ID is missing from the environment, we assume + // no SDK credentials are available. This prevents the AWS SDK from + // falling back to the Instance Metadata Service + // which causes a 5+ second connection timeout on non-AWS environments. + if (!getenv('AWS_ACCESS_KEY_ID')) { + return ''; + } + $config->s3_usesdkcreds = 1; $this->set_client($config); $connection = $this->test_connection();