mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
Fix the error with S3Client being null
This commit is contained in:
parent
9222af21e8
commit
8638c229a8
2 changed files with 8 additions and 2 deletions
|
@ -11,7 +11,13 @@ class ObjectStorageServiceProvider extends ServiceProvider
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->bind(S3ClientInterface::class, static function (): AwsClientInterface {
|
||||
$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;
|
||||
}
|
||||
|
||||
return AWS::createClient('s3');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class S3Service implements ObjectStorageInterface
|
|||
private $s3Client;
|
||||
private $cache;
|
||||
|
||||
public function __construct(S3ClientInterface $s3Client, Cache $cache)
|
||||
public function __construct(?S3ClientInterface $s3Client, Cache $cache)
|
||||
{
|
||||
$this->s3Client = $s3Client;
|
||||
$this->cache = $cache;
|
||||
|
|
Loading…
Reference in a new issue