From 2adb18316f719070e2ff4f51f9071025451fe702 Mon Sep 17 00:00:00 2001 From: Frostist Date: Mon, 17 Mar 2025 16:00:42 +0200 Subject: [PATCH] Added Path Style Endpoint Used for alternative software endpoints like MinIo --- classes/local/store/s3/client.php | 6 ++++++ lang/en/tool_objectfs.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index 54e62bda..8b55b71f 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -167,6 +167,8 @@ public function set_client($config) { 'version' => AWS_API_VERSION, ]; + $options['use_path_style_endpoint'] = !empty($config->use_path_style_endpoint); + if (empty($config->s3_usesdkcreds)) { $options['credentials'] = ['key' => $config->s3_key, 'secret' => $config->s3_secret]; } @@ -475,6 +477,10 @@ public function define_client_section($settings, $config) { new \lang_string('settings:aws:key_prefix', 'tool_objectfs'), new \lang_string('settings:aws:key_prefix_help', 'tool_objectfs'), '')); + $settings->add(new \admin_setting_configcheckbox('tool_objectfs/use_path_style_endpoint', + new \lang_string('settings:aws:use_path_style_endpoint', 'tool_objectfs'), + new \lang_string('settings:aws:use_path_style_endpoint_help', 'tool_objectfs'), 1)); + return $settings; } diff --git a/lang/en/tool_objectfs.php b/lang/en/tool_objectfs.php index b5f2303c..8c2c87b2 100644 --- a/lang/en/tool_objectfs.php +++ b/lang/en/tool_objectfs.php @@ -125,6 +125,8 @@ $string['settings:aws:sdkcredserror'] = 'Couldn\'t find AWS credentials. It\'s unsafe to enable this setting. Follow up AWS documentation.'; $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:use_path_style_endpoint'] = 'Use path-style endpoint'; +$string['settings:aws:use_path_style_endpoint_help'] = 'Enable this to use path-style S3 endpoint URLs (e.g., https://s3.amazonaws.com/bucket/key) instead of virtual-hosted style URLs (e.g., https://bucket.s3.amazonaws.com/key). This is required for some S3-compatible storage services like MinIO.'; $string['settings:do:header'] = 'DigitalOcean Spaces Settings'; $string['settings:do:key'] = 'Key';