Chevereto使用S3策略时如果发现是域名链接,会自动以DNS style模式在域名前面加上bucket名称。
可以使用代码使Chevereto强制使用路径模式。
本文基于Chevereto 4.0.9修改,3.x的路径请自己找一下。
修改文件
/app/src/Legacy/Classes/Storage.php
大约在510行左右,将以下代码,
case 's3compatible':
$factoria = [
'version' => '2006-03-01',
'region' => $storage['region'],
'command.params' => ['PathStyle' => true],
'credentials' => [
'key' => $storage['key'],
'secret' => $storage['secret'],
],
'http' => [
'verify' => CaBundle::getBundledCaBundlePath(),
],
];
if ($api_type == 's3compatible') {
$factoria['endpoint'] = $storage['server'];
}
return new S3Client($factoria);
替换为以下代码
case 's3compatible':
$factoria = [
'version' => '2006-03-01',
'region' => $storage['region'],
'command.params' => ['PathStyle' => true],
'credentials' => [
'key' => $storage['key'],
'secret' => $storage['secret'],
],
'http' => [
'verify' => CaBundle::getBundledCaBundlePath(),
],
'use_path_style_endpoint' => true,
];
if ($api_type == 's3compatible') {
$factoria['endpoint'] = $storage['server'];
}
return new S3Client($factoria);
现在去后台就可以正常添加了。