feat: review comments
This commit is contained in:
parent
8b431a8e44
commit
d830f5c262
3 changed files with 69 additions and 50 deletions
|
@ -507,14 +507,6 @@ return [
|
|||
'question' => '',
|
||||
'filter' => ''
|
||||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_DEVICE', // TODO : Should we keep it or deprecate it considering we can get the device from the scheme of the DSN
|
||||
'description' => 'Select default storage device. The default value is \'Local\'. List of supported adapters are \'Local\', \'S3\', \'DOSpaces\', \'Backblaze\', \'Linode\' and \'Wasabi\'.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => 'Local',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
],
|
||||
[
|
||||
'name' => '_APP_CONNECTIONS_STORAGE',
|
||||
'description' => 'A DSN representing the storage device to connect to. The DSN takes the following format <device>://<access_key>:<access_secret>@<host>:<port>/<bucket>?region=<region>. For example, for S3: \'s3://access_key:access_secret@host:port/bucket?region=us-east-1\'. To use the local filesystem, you can leave this variable empty.',
|
||||
|
@ -523,9 +515,17 @@ return [
|
|||
'required' => false,
|
||||
'question' => '',
|
||||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_DEVICE',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => 'Local',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_S3_ACCESS_KEY',
|
||||
'description' => 'Deprecated since 1.1.0. AWS S3 storage access key. Required when the storage adapter is set to S3. You can get your access key from your AWS console',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -533,7 +533,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_S3_SECRET',
|
||||
'description' => 'AWS S3 storage secret key. Required when the storage adapter is set to S3. You can get your secret key from your AWS console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -541,7 +541,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_S3_REGION',
|
||||
'description' => 'AWS S3 storage region. Required when storage adapter is set to S3. You can find your region info for your bucket from AWS console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => 'us-east-1',
|
||||
'required' => false,
|
||||
|
@ -549,7 +549,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_S3_BUCKET',
|
||||
'description' => 'AWS S3 storage bucket. Required when storage adapter is set to S3. You can create buckets in your AWS console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -557,7 +557,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_DO_SPACES_ACCESS_KEY',
|
||||
'description' => 'DigitalOcean spaces access key. Required when the storage adapter is set to DOSpaces. You can get your access key from your DigitalOcean console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -565,7 +565,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_DO_SPACES_SECRET',
|
||||
'description' => 'DigitalOcean spaces secret key. Required when the storage adapter is set to DOSpaces. You can get your secret key from your DigitalOcean console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -573,7 +573,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_DO_SPACES_REGION',
|
||||
'description' => 'DigitalOcean spaces region. Required when storage adapter is set to DOSpaces. You can find your region info for your space from DigitalOcean console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => 'us-east-1',
|
||||
'required' => false,
|
||||
|
@ -581,7 +581,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_DO_SPACES_BUCKET',
|
||||
'description' => 'DigitalOcean spaces bucket. Required when storage adapter is set to DOSpaces. You can create spaces in your DigitalOcean console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.13.0',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -589,7 +589,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_BACKBLAZE_ACCESS_KEY',
|
||||
'description' => 'Backblaze access key. Required when the storage adapter is set to Backblaze. Your Backblaze keyID will be your access key. You can get your keyID from your Backblaze console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -597,7 +597,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_BACKBLAZE_SECRET',
|
||||
'description' => 'Backblaze secret key. Required when the storage adapter is set to Backblaze. Your Backblaze applicationKey will be your secret key. You can get your applicationKey from your Backblaze console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -605,7 +605,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_BACKBLAZE_REGION',
|
||||
'description' => 'Backblaze region. Required when storage adapter is set to Backblaze. You can find your region info from your Backblaze console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => 'us-west-004',
|
||||
'required' => false,
|
||||
|
@ -613,7 +613,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_BACKBLAZE_BUCKET',
|
||||
'description' => 'Backblaze bucket. Required when storage adapter is set to Backblaze. You can create your bucket from your Backblaze console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -621,7 +621,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_LINODE_ACCESS_KEY',
|
||||
'description' => 'Linode object storage access key. Required when the storage adapter is set to Linode. You can get your access key from your Linode console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -629,7 +629,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_LINODE_SECRET',
|
||||
'description' => 'Linode object storage secret key. Required when the storage adapter is set to Linode. You can get your secret key from your Linode console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -637,7 +637,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_LINODE_REGION',
|
||||
'description' => 'Linode object storage region. Required when storage adapter is set to Linode. You can find your region info from your Linode console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => 'eu-central-1',
|
||||
'required' => false,
|
||||
|
@ -645,7 +645,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_LINODE_BUCKET',
|
||||
'description' => 'Linode object storage bucket. Required when storage adapter is set to Linode. You can create buckets in your Linode console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -653,7 +653,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_WASABI_ACCESS_KEY',
|
||||
'description' => 'Wasabi access key. Required when the storage adapter is set to Wasabi. You can get your access key from your Wasabi console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -661,7 +661,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_WASABI_SECRET',
|
||||
'description' => 'Wasabi secret key. Required when the storage adapter is set to Wasabi. You can get your secret key from your Wasabi console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
@ -669,7 +669,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_WASABI_REGION',
|
||||
'description' => 'Wasabi region. Required when storage adapter is set to Wasabi. You can find your region info from your Wasabi console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => 'eu-central-1',
|
||||
'required' => false,
|
||||
|
@ -677,7 +677,7 @@ return [
|
|||
],
|
||||
[
|
||||
'name' => '_APP_STORAGE_WASABI_BUCKET',
|
||||
'description' => 'Wasabi bucket. Required when storage adapter is set to Wasabi. You can create buckets in your Wasabi console.',
|
||||
'description' => 'Deprecated since 1.2.0. Use _APP_CONNECTIONS_STORAGE instead.',
|
||||
'introduction' => '0.14.2',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
|
39
app/init.php
39
app/init.php
|
@ -159,6 +159,13 @@ const DELETE_TYPE_SCHEDULES = 'schedules';
|
|||
const COMPRESSION_TYPE_NONE = 'none';
|
||||
const COMPRESSION_TYPE_GZIP = 'gzip';
|
||||
const COMPRESSION_TYPE_ZSTD = 'zstd';
|
||||
// Storage Device Types
|
||||
const STORAGE_DEVICE_LOCAL = 'file';
|
||||
const STORAGE_DEVICE_S3 = 's3';
|
||||
const STORAGE_DEVICE_DO_SPACES = 'dospaces';
|
||||
const STORAGE_DEVICE_BACKBLAZE= 'backblaze';
|
||||
const STORAGE_DEVICE_LINODE = 'linode';
|
||||
const STORAGE_DEVICE_WASABI = 'wasabi';
|
||||
// Mail Types
|
||||
const MAIL_TYPE_VERIFICATION = 'verification';
|
||||
const MAIL_TYPE_MAGIC_SESSION = 'magicSession';
|
||||
|
@ -1100,6 +1107,13 @@ function getDevice($root): Device
|
|||
{
|
||||
$connection = App::getEnv('_APP_CONNECTIONS_STORAGE', '');
|
||||
|
||||
$acl = 'private';
|
||||
$device = '';
|
||||
$accessKey = '';
|
||||
$accessSecret = '';
|
||||
$bucket = '';
|
||||
$region = '';
|
||||
|
||||
try {
|
||||
$dsn = new DSN($connection);
|
||||
$device = $dsn->getScheme();
|
||||
|
@ -1107,26 +1121,25 @@ function getDevice($root): Device
|
|||
$accessSecret = $dsn->getPassword();
|
||||
$bucket = $dsn->getPath();
|
||||
$region = $dsn->getParam('region');
|
||||
$acl = 'private';
|
||||
} catch (\Exception $e) {
|
||||
Console::error($e->getMessage() . 'Defaulting to Local storage.');
|
||||
Console::error($e->getMessage() . 'Invalid DSN. Defaulting to Local storage.');
|
||||
$device = 'Local';
|
||||
}
|
||||
|
||||
switch ($device) {
|
||||
case Storage::DEVICE_LOCAL:
|
||||
case STORAGE_DEVICE_S3:
|
||||
return new S3($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case STORAGE_DEVICE_DO_SPACES:
|
||||
return new DOSpaces($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case STORAGE_DEVICE_BACKBLAZE:
|
||||
return new Backblaze($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case STORAGE_DEVICE_LINODE:
|
||||
return new Linode($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case STORAGE_DEVICE_WASABI:
|
||||
return new Wasabi($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case STORAGE_DEVICE_LOCAL:
|
||||
default:
|
||||
return new Local($root);
|
||||
case Storage::DEVICE_S3:
|
||||
return new S3($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case Storage::DEVICE_DO_SPACES:
|
||||
return new DOSpaces($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case Storage::DEVICE_BACKBLAZE:
|
||||
return new Backblaze($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case Storage::DEVICE_LINODE:
|
||||
return new Linode($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case Storage::DEVICE_WASABI:
|
||||
return new Wasabi($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -279,6 +279,13 @@ abstract class Worker
|
|||
{
|
||||
$connection = App::getEnv('_APP_CONNECTIONS_STORAGE', '');
|
||||
|
||||
$acl = 'private';
|
||||
$device = '';
|
||||
$accessKey = '';
|
||||
$accessSecret = '';
|
||||
$bucket = '';
|
||||
$region = '';
|
||||
|
||||
try {
|
||||
$dsn = new DSN($connection);
|
||||
$device = $dsn->getScheme();
|
||||
|
@ -286,24 +293,23 @@ abstract class Worker
|
|||
$accessSecret = $dsn->getPassword();
|
||||
$bucket = $dsn->getPath();
|
||||
$region = $dsn->getParam('region');
|
||||
$acl = 'private';
|
||||
} catch (\Exception $e) {
|
||||
Console::error($e->getMessage() . 'Defaulting to Local storage.');
|
||||
$device = 'Local';
|
||||
Console::error($e->getMessage() . 'Invalid DSN. Defaulting to Local storage.');
|
||||
$device = 'file';
|
||||
}
|
||||
|
||||
switch ($device) {
|
||||
case Storage::DEVICE_S3:
|
||||
case STORAGE_DEVICE_S3:
|
||||
return new S3($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case Storage::DEVICE_DO_SPACES:
|
||||
case STORAGE_DEVICE_DO_SPACES:
|
||||
return new DOSpaces($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case Storage::DEVICE_BACKBLAZE:
|
||||
case STORAGE_DEVICE_BACKBLAZE:
|
||||
return new Backblaze($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case Storage::DEVICE_LINODE:
|
||||
case STORAGE_DEVICE_LINODE:
|
||||
return new Linode($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case Storage::DEVICE_WASABI:
|
||||
case STORAGE_DEVICE_WASABI:
|
||||
return new Wasabi($root, $accessKey, $accessSecret, $bucket, $region, $acl);
|
||||
case Storage::DEVICE_LOCAL:
|
||||
case STORAGE_DEVICE_LOCAL:
|
||||
default:
|
||||
return new Local($root);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue