s3 storage endpoint param

This commit is contained in:
Yuri Kuznetsov
2023-12-09 11:01:48 +02:00
parent 9e3f834b04
commit 9216964801
@@ -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);