2023-08-07 13:31:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Models\S3Storage;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
2023-08-08 09:51:36 +00:00
|
|
|
function set_s3_target(S3Storage $s3)
|
|
|
|
{
|
2023-08-07 13:31:42 +00:00
|
|
|
$is_digital_ocean = false;
|
|
|
|
if ($s3->endpoint) {
|
2023-08-08 09:51:36 +00:00
|
|
|
$is_digital_ocean = Str::contains($s3->endpoint, 'digitaloceanspaces.com');
|
2023-08-07 13:31:42 +00:00
|
|
|
}
|
|
|
|
config()->set('filesystems.disks.custom-s3', [
|
2023-08-08 09:51:36 +00:00
|
|
|
'driver' => 's3',
|
|
|
|
'region' => $s3['region'],
|
|
|
|
'key' => $s3['key'],
|
|
|
|
'secret' => $s3['secret'],
|
|
|
|
'bucket' => $s3['bucket'],
|
|
|
|
'endpoint' => $s3['endpoint'],
|
|
|
|
'use_path_style_endpoint' => true,
|
|
|
|
'bucket_endpoint' => $is_digital_ocean,
|
|
|
|
'aws_url' => $s3->awsUrl(),
|
2023-08-07 13:31:42 +00:00
|
|
|
]);
|
2023-08-08 09:51:36 +00:00
|
|
|
}
|