koel/app/Providers/ObjectStorageServiceProvider.php

24 lines
687 B
PHP
Raw Normal View History

2018-08-29 04:06:17 +00:00
<?php
namespace App\Providers;
use Aws\AwsClientInterface;
use Aws\S3\S3ClientInterface;
use Illuminate\Support\ServiceProvider;
class ObjectStorageServiceProvider extends ServiceProvider
{
public function register(): void
{
2018-08-29 10:18:42 +00:00
$this->app->bind(S3ClientInterface::class, static function (): ?AwsClientInterface {
// If these two values are not configured in .env, AWS will attempt initializing
// the client with null values and throw an error.
if (!config('aws.credentials.key') || !config('aws.credentials.secret')) {
return null;
}
2018-08-31 13:47:15 +00:00
return app('aws')->createClient('s3');
2018-08-29 04:06:17 +00:00
});
}
}