From 06ce94a77d81cd37cfc02616b8247c0d8459150f Mon Sep 17 00:00:00 2001 From: nanaya Date: Wed, 26 Jul 2023 14:26:28 +0900 Subject: [PATCH] Add support for non-aws s3 compatible storage --- .env.example | 3 +++ config/filesystems.php | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.env.example b/.env.example index c992bc4df73..9a43b525a22 100644 --- a/.env.example +++ b/.env.example @@ -69,6 +69,9 @@ SLACK_ENDPOINT=https://myconan.net/null/ # S3_BASE_URL= # S3_MINI_URL= +# S3_ENDPOINT= +# S3_USE_PATH_STYLE_ENDPOINT=false + # S3_SOLO_REPLAY_BUCKET=solo-scores-replays # S3_AVATAR_KEY= diff --git a/config/filesystems.php b/config/filesystems.php index a2721b61cfe..eff38e7473f 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -1,5 +1,15 @@ env('S3_BUCKET'), + 'driver' => 's3', + 'endpoint' => env('S3_ENDPOINT'), + 'key' => env('S3_KEY'), + 'region' => env('S3_REGION'), + 'secret' => env('S3_SECRET'), + 'use_path_style_endpoint' => get_bool(env('S3_USE_PATH_STYLE_ENDPOINT')) ?? false, +]; + foreach (['osu', 'taiko', 'fruits', 'mania'] as $mode) { $replays[$mode] = [ 'local' => [ @@ -8,10 +18,7 @@ ], 's3' => [ - 'driver' => 's3', - 'key' => env('S3_KEY'), - 'secret' => env('S3_SECRET'), - 'region' => env('S3_REGION'), + ...$s3Default, 'bucket' => "replay-{$mode}", ], ]; @@ -79,29 +86,22 @@ ], 's3' => [ - 'driver' => 's3', - 'key' => env('S3_KEY'), - 'secret' => env('S3_SECRET'), - 'region' => env('S3_REGION'), - 'bucket' => env('S3_BUCKET'), + ...$s3Default, 'base_url' => env('S3_BASE_URL'), 'mini_url' => env('S3_MINI_URL') ?? env('S3_BASE_URL'), ], 's3-avatar' => [ - 'driver' => 's3', + ...$s3Default, + 'base_url' => env('S3_AVATAR_BASE_URL'), + 'bucket' => env('S3_AVATAR_BUCKET'), 'key' => env('S3_AVATAR_KEY'), - 'secret' => env('S3_AVATAR_SECRET'), 'region' => env('S3_AVATAR_REGION'), - 'bucket' => env('S3_AVATAR_BUCKET'), - 'base_url' => env('S3_AVATAR_BASE_URL'), + 'secret' => env('S3_AVATAR_SECRET'), ], 's3-solo-replay' => [ - 'driver' => 's3', - 'key' => env('S3_KEY'), - 'secret' => env('S3_SECRET'), - 'region' => env('S3_REGION'), + ...$s3Default, 'bucket' => presence(env('S3_SOLO_REPLAY_BUCKET')) ?? 'solo-scores-replays', ], ],