mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-12 06:48:55 +00:00
daec0a877e
External storage meant S3 and nothing else, which is an odd hole for a product whose users are as likely to be standing on Google Cloud as on AWS — and paying to move bytes between two clouds to use this. The Storage screen now asks which provider first, and the answer decides which fields it shows, which it validates, and which driver the files_external disk resolves to. One disk, not two. files.disk is a stored column, so a third disk name would fragment the data model and make every $file->disk consumer know three names instead of two; the driver is swapped instead. A service account key gets its own encrypted column rather than sharing `secret`, because the two are validated, labelled and displayed differently and one column meaning two things is how that goes wrong later. Three things do not work by simply adding the adapter, and all three fail quietly: Laravel's temporaryUrl() looks for getTemporaryUrl() on the adapter, while League's GCS adapter names it temporaryUrl(), so without the registered callback every download and preview is a 500. The two SDKs spell the signing options differently, and an unrecognised one is dropped in silence — the symptom is a download named after the storage key, not an exception. GoogleCloudStorageDriver translates, so callers keep speaking one vocabulary, and the test asserts on the URL's contents rather than on "a redirect happened", which is what would let it regress. That callback is also re-bound to the FilesystemAdapter before it runs, so the translation is captured before registering rather than called as $this-> `provider` is validated with 'sometimes', not 'required': absent means S3, which is what every payload written before this choice meant, and stops a browser holding a stale bundle from failing to save on a field it cannot see. Verified in a browser as well as in tests — which is how the null provider on an unmigrated row was found, since the suite migrates and never sees that state.
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Platform\Settings;
|
|
|
|
/**
|
|
* Which object store the external `files_external` disk is talking to.
|
|
*
|
|
* Unlike MailProvider, this is not a preset picker over one transport:
|
|
* the two cases are genuinely different Flysystem drivers, authenticated
|
|
* differently — an access key and secret against an S3 API, a service
|
|
* account key against Google's. Which fields the Storage settings screen
|
|
* shows, which of them are validated, and what
|
|
* ExternalStorageConfigApplier writes into the disk config all follow
|
|
* from this.
|
|
*
|
|
* S3 keeps its endpoint and path-style settings because "S3" here means
|
|
* the whole S3-compatible family — AWS itself, MinIO, Backblaze,
|
|
* Wasabi, and Google's own interoperability endpoint for anyone who
|
|
* would rather use HMAC keys than a service account.
|
|
*/
|
|
enum StorageProvider: string
|
|
{
|
|
case S3 = 's3';
|
|
case Gcs = 'gcs';
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::S3 => 'S3-compatible',
|
|
self::Gcs => 'Google Cloud Storage',
|
|
};
|
|
}
|
|
|
|
/** The Laravel filesystem driver this provider is served by. */
|
|
public function driver(): string
|
|
{
|
|
return match ($this) {
|
|
self::S3 => 's3',
|
|
self::Gcs => 'gcs',
|
|
};
|
|
}
|
|
}
|