Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix(core): improve connection testing with dynamic disk configuration for s3 backups

Andras Bacsaib53e289bcd46
diff --git a/app/Models/S3Storage.php b/app/Models/S3Storage.php
index 5a9eb87a3c..e9d6746502 100644
--- a/app/Models/S3Storage.php
+++ b/app/Models/S3Storage.php
@@ -43,8 +43,18 @@ class S3Storage extends BaseModel
public function testConnection(bool $shouldSave = false)
{
try {
- set_s3_target($this);
- Storage::disk('custom-s3')->files();
+ $disk = Storage::build([
+ 'driver' => 's3',
+ 'region' => $this['region'],
+ 'key' => $this['key'],
+ 'secret' => $this['secret'],
+ 'bucket' => $this['bucket'],
+ 'endpoint' => $this['endpoint'],
+ 'use_path_style_endpoint' => true,
+ ]);
+ // Test the connection by listing files with ListObjectsV2 (S3)
+ $disk->files();
+
$this->unusable_email_sent = false;
$this->is_usable = true;
} catch (\Throwable $e) {
diff --git a/bootstrap/helpers/s3.php b/bootstrap/helpers/s3.php
deleted file mode 100644
index 7029377a4b..0000000000
--- a/bootstrap/helpers/s3.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-use App\Models\S3Storage;
-
-function set_s3_target(S3Storage $s3)
-{
- config()->set('filesystems.disks.custom-s3', [
- 'driver' => 's3',
- 'region' => $s3['region'],
- 'key' => $s3['key'],
- 'secret' => $s3['secret'],
- 'bucket' => $s3['bucket'],
- 'endpoint' => $s3['endpoint'],
- 'use_path_style_endpoint' => true,
- 'aws_url' => $s3->awsUrl(),
- ]);
-}