From 92169648015ca0a4d7fc9c4655061db7e990ee52 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sat, 9 Dec 2023 11:01:48 +0200 Subject: [PATCH] s3 storage endpoint param --- .../Espo/Core/FileStorage/Storages/AwsS3.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/application/Espo/Core/FileStorage/Storages/AwsS3.php b/application/Espo/Core/FileStorage/Storages/AwsS3.php index dfed8d392a..a1888037fb 100644 --- a/application/Espo/Core/FileStorage/Storages/AwsS3.php +++ b/application/Espo/Core/FileStorage/Storages/AwsS3.php @@ -52,9 +52,10 @@ class AwsS3 implements Storage { $bucketName = $config->get('awsS3Storage.bucketName') ?? null; $path = $config->get('awsS3Storage.path') ?? null; - $region = $config->get('awsS3Storage.region') ?? null; $credentials = $config->get('awsS3Storage.credentials') ?? null; + $endpoint = $config->get('awsS3Storage.endpoint') ?? null; + $pathStyleEndpoint = $config->get('awsS3Storage.pathStyleEndpoint') ?? false; if (!$bucketName) { throw new RuntimeException("AWS S3 bucket name is not specified in config."); @@ -64,13 +65,20 @@ class AwsS3 implements Storage 'region' => $region, ]; - if ($credentials) { + if ($endpoint) { + $clientOptions['endpoint'] = $endpoint; + } + + if ($pathStyleEndpoint) { + $clientOptions['pathStyleEndpoint'] = (bool) $pathStyleEndpoint; + } + + if ($credentials && is_array($credentials)) { $clientOptions['accessKeyId'] = $credentials['key'] ?? null; $clientOptions['accessKeySecret'] = $credentials['secret'] ?? null; } $client = new S3Client($clientOptions); - $adapter = new AsyncAwsS3Adapter($client, $bucketName, $path); $this->filesystem = new Filesystem($adapter);