Skip to content

Commit ef7724a

Browse files
ENGCOM-9178: Support S3 compatible storage #32937
2 parents e1b9024 + c722930 commit ef7724a

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

app/code/Magento/AwsS3/Driver/AwsS3Factory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ public function createConfigured(
116116
$config['http_handler'] = $this->objectManager->create($config['http_handler'])($config);
117117
}
118118

119+
if (!empty($config['path_style'])) {
120+
$config['use_path_style_endpoint'] = boolval($config['path_style']);
121+
}
122+
119123
$client = new S3Client($config);
120124
$adapter = new AwsS3V3Adapter($client, $config['bucket'], $prefix);
121125
$cache = $this->cacheInterfaceFactory->create(

app/code/Magento/AwsS3/Model/Config.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
*/
1515
class Config
1616
{
17+
public const PATH_ENDPOINT = 'remote_storage/endpoint';
1718
public const PATH_REGION = 'remote_storage/region';
1819
public const PATH_BUCKET = 'remote_storage/bucket';
1920
public const PATH_ACCESS_KEY = 'remote_storage/access_key';
2021
public const PATH_SECRET_KEY = 'remote_storage/secret_key';
2122
public const PATH_PREFIX = 'remote_storage/prefix';
23+
public const PATH_PATH_STYLE = 'remote_storage/path_style';
2224

2325
/**
2426
* @var DeploymentConfig
@@ -33,6 +35,16 @@ public function __construct(DeploymentConfig $config)
3335
$this->config = $config;
3436
}
3537

38+
/**
39+
* Retrieves endpoint.
40+
*
41+
* @return string
42+
*/
43+
public function getEndpoint(): string
44+
{
45+
return (string)$this->config->get(self::PATH_ENDPOINT);
46+
}
47+
3648
/**
3749
* Retrieves region.
3850
*
@@ -82,4 +94,14 @@ public function getPrefix(): string
8294
{
8395
return (string)$this->config->get(self::PATH_PREFIX, '');
8496
}
97+
98+
/**
99+
* Retrieves endpoint.
100+
*
101+
* @return string
102+
*/
103+
public function getPathStyle(): string
104+
{
105+
return (string)$this->config->get(self::PATH_PATH_STYLE, '0');
106+
}
85107
}

app/code/Magento/RemoteStorage/Setup/ConfigOptionsList.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class ConfigOptionsList implements ConfigOptionsListInterface
2727
private const CONFIG_PATH__REMOTE_STORAGE_DRIVER = RemoteDriverPool::PATH_DRIVER;
2828
private const OPTION_REMOTE_STORAGE_PREFIX = 'remote-storage-prefix';
2929
private const CONFIG_PATH__REMOTE_STORAGE_PREFIX = RemoteDriverPool::PATH_PREFIX;
30+
private const OPTION_REMOTE_STORAGE_ENDPOINT = 'remote-storage-endpoint';
31+
private const CONFIG_PATH__REMOTE_STORAGE_ENDPOINT = RemoteDriverPool::PATH_CONFIG . '/endpoint';
3032
private const OPTION_REMOTE_STORAGE_BUCKET = 'remote-storage-bucket';
3133
private const CONFIG_PATH__REMOTE_STORAGE_BUCKET = RemoteDriverPool::PATH_CONFIG . '/bucket';
3234
private const OPTION_REMOTE_STORAGE_REGION = 'remote-storage-region';
@@ -35,6 +37,8 @@ class ConfigOptionsList implements ConfigOptionsListInterface
3537
private const CONFIG_PATH__REMOTE_STORAGE_ACCESS_KEY = RemoteDriverPool::PATH_CONFIG . '/credentials/key';
3638
private const OPTION_REMOTE_STORAGE_SECRET_KEY = 'remote-storage-secret';
3739
private const CONFIG_PATH__REMOTE_STORAGE_SECRET_KEY = RemoteDriverPool::PATH_CONFIG . '/credentials/secret';
40+
private const OPTION_REMOTE_STORAGE_PATH_STYLE = 'remote-storage-path-style';
41+
private const CONFIG_PATH__REMOTE_STORAGE_PATH_STYLE = RemoteDriverPool::PATH_CONFIG . '/path-style';
3842

3943
/**
4044
* Map of option to config path relations.
@@ -43,10 +47,12 @@ class ConfigOptionsList implements ConfigOptionsListInterface
4347
*/
4448
private static $map = [
4549
self::OPTION_REMOTE_STORAGE_PREFIX => self::CONFIG_PATH__REMOTE_STORAGE_PREFIX,
50+
self::OPTION_REMOTE_STORAGE_ENDPOINT => self::CONFIG_PATH__REMOTE_STORAGE_ENDPOINT,
4651
self::OPTION_REMOTE_STORAGE_BUCKET => self::CONFIG_PATH__REMOTE_STORAGE_BUCKET,
4752
self::OPTION_REMOTE_STORAGE_REGION => self::CONFIG_PATH__REMOTE_STORAGE_REGION,
4853
self::OPTION_REMOTE_STORAGE_ACCESS_KEY => self::CONFIG_PATH__REMOTE_STORAGE_ACCESS_KEY,
49-
self::OPTION_REMOTE_STORAGE_SECRET_KEY => self::CONFIG_PATH__REMOTE_STORAGE_SECRET_KEY
54+
self::OPTION_REMOTE_STORAGE_SECRET_KEY => self::CONFIG_PATH__REMOTE_STORAGE_SECRET_KEY,
55+
self::OPTION_REMOTE_STORAGE_PATH_STYLE => self::CONFIG_PATH__REMOTE_STORAGE_PATH_STYLE
5056
];
5157

5258
/**
@@ -89,6 +95,12 @@ public function getOptions(): array
8995
'Remote storage prefix',
9096
''
9197
),
98+
new TextConfigOption(
99+
self::OPTION_REMOTE_STORAGE_ENDPOINT,
100+
TextConfigOption::FRONTEND_WIZARD_TEXT,
101+
self::CONFIG_PATH__REMOTE_STORAGE_ENDPOINT,
102+
'Remote storage endpoint'
103+
),
92104
new TextConfigOption(
93105
self::OPTION_REMOTE_STORAGE_BUCKET,
94106
TextConfigOption::FRONTEND_WIZARD_TEXT,
@@ -114,6 +126,13 @@ public function getOptions(): array
114126
self::CONFIG_PATH__REMOTE_STORAGE_SECRET_KEY,
115127
'Remote storage secret key',
116128
''
129+
),
130+
new TextConfigOption(
131+
self::OPTION_REMOTE_STORAGE_PATH_STYLE,
132+
TextConfigOption::FRONTEND_WIZARD_PASSWORD,
133+
self::CONFIG_PATH__REMOTE_STORAGE_PATH_STYLE,
134+
'Remote storage path style',
135+
'0'
117136
)
118137
];
119138
}

0 commit comments

Comments
 (0)