fix: local dev s3 uploads

fix: hetzner s3 uploads (mc alias instead of mc host)
This commit is contained in:
Andras Bacsai
2024-10-02 11:45:30 +02:00
parent 2be2f0ac79
commit dd782e75f5
6 changed files with 50 additions and 36 deletions

View File

@@ -1,15 +1,11 @@
<?php
use App\Models\S3Storage;
use Illuminate\Support\Str;
function set_s3_target(S3Storage $s3)
{
$is_digital_ocean = false;
if ($s3->endpoint) {
$is_digital_ocean = Str::contains($s3->endpoint, 'digitaloceanspaces.com');
$is_hetzner = Str::contains($s3->endpoint, 'your-objectstorage.com');
}
config()->set('filesystems.disks.custom-s3', [
'driver' => 's3',
'region' => $s3['region'],
@@ -18,7 +14,7 @@ function set_s3_target(S3Storage $s3)
'bucket' => $s3['bucket'],
'endpoint' => $s3['endpoint'],
'use_path_style_endpoint' => true,
'bucket_endpoint' => $is_digital_ocean || $is_hetzner,
'bucket_endpoint' => $s3->isHetzner() || $s3->isDigitalOcean(),
'aws_url' => $s3->awsUrl(),
]);
}